summaryrefslogtreecommitdiffstats
path: root/Services/nodejs/run.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Services/nodejs/run.sh')
-rw-r--r--Services/nodejs/run.sh28
1 files changed, 17 insertions, 11 deletions
diff --git a/Services/nodejs/run.sh b/Services/nodejs/run.sh
index cc94229..870958a 100644
--- a/Services/nodejs/run.sh
+++ b/Services/nodejs/run.sh
@@ -5,11 +5,11 @@ source /bin/sx-lib.sh
function check_nodejs_environment {
check_environment
if [ ! -v APP_PATH ]; then
- APP_PATH="/data/nodejs"
+ APP_PATH="/data"
export APP_PATH
fi
if [ ! -v LOG_PATH ]; then
- LOG_PATH="/data/logs/nodejs"
+ LOG_PATH="/logs"
export LOG_PATH
fi
}
@@ -59,20 +59,26 @@ function end_config {
echo "=> END NODEJS CONFIGURATION"
}
+function stop_nodejs_handler {
+ killall node
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now STOPPED" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ exit 143; # 128 + 15 -- SIGTERM
+}
+
# Start the nodejs executable with application entrypoint
# the running shell
-function start_daemon {
- echo "=> Starting nodejs daemon ..." | tee -a $STARTUPLOG
- display_container_started | tee -a $STARTUPLOG
- exec node $APP_MAIN
+function start_service_nodejs {
+ trap 'kill ${!}; stop_nodejs_handler' SIGHUP SIGINT SIGQUIT SIGTERM SIGKILL SIGSTOP SIGCONT
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ echo "| Container $HOSTNAME is now RUNNING" | tee -a $STARTUPLOG
+ echo "+=====================================================" | tee -a $STARTUPLOG
+ exec node $APP_MAIN
}
-if [[ "$0" == *"run.sh" && ! $1 = "" ]];then
- eval "$@";
-fi
-
check_nodejs_environment | tee -a $STARTUPLOG
display_container_nodejs_header | tee -a $STARTUPLOG
begin_config | tee -a $STARTUPLOG
end_config | tee -a $STARTUPLOG
-start_daemon
+start_service_nodejs