From c3f1118c629582ae3baac5da5e8e04bebf16325c Mon Sep 17 00:00:00 2001 From: Difrex Date: Thu, 4 Aug 2016 13:16:37 +0300 Subject: [PATCH] reload.sh temp --- reload.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 reload.sh diff --git a/reload.sh b/reload.sh new file mode 100755 index 0000000..d2b0464 --- /dev/null +++ b/reload.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +echo "invoke reload ${APP_NAME} `date`" + +APP_PATH='/app' +APP_RUN='node app.js -c /app/conf.json' +APP_MASTER_NAME='node' + + +function run_reload() { + ( + cd $APP_PATH + echo "$$" > /tmp/spid${APP_NAME} + $APP_RUN + )& +} + + +if [[ -e /tmp/spid${APP_NAME} ]]; then + SPID=`cat /tmp/spid${APP_NAME}` +fi + +if [[ -z $SPID ]]; then + run_reload +else + killall -9 $APP_MASTER_NAME + run_reload +fi