From fbfa9eb91af30153c959f2b9b5ce2b4a0fef4522 Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Tue, 22 Nov 2016 14:41:42 -0600 Subject: [PATCH] Completes POCONSOLE-70. finishes startup scripts for twisted production server --- datalogger.sh | 10 ++++++---- start.sh | 2 +- stop.sh | 4 ---- 3 files changed, 7 insertions(+), 9 deletions(-) delete mode 100644 stop.sh diff --git a/datalogger.sh b/datalogger.sh index ea0984f..400bc1d 100644 --- a/datalogger.sh +++ b/datalogger.sh @@ -11,16 +11,17 @@ SCRIPT=/root/www/start.sh RUNAS=poconsole -PIDFILE=/var/run/datalogger.pid +PIDFILE=/root/datalogger.pid +LOGFILE=/root/datalogger.log start() { - if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then + if [ -f "$PIDFILE" ] && kill -0 $(cat $PIDFILE); then echo 'Service already running' >&2 return 1 fi echo 'Starting service…' >&2 - local CMD="$SCRIPT & echo \$!" - su -c "$CMD" $RUNAS + local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!" + su -c "$CMD" $RUNAS > /dev/null echo 'Service started' >&2 } @@ -41,6 +42,7 @@ uninstall() { if [ "$SURE" = "yes" ]; then stop rm -f "$PIDFILE" + echo "Notice: log file is not be removed: '$LOGFILE'" >&2 update-rc.d -f datalogger remove rm -fv "$0" fi diff --git a/start.sh b/start.sh index d68454e..279c52d 100644 --- a/start.sh +++ b/start.sh @@ -1,5 +1,5 @@ #!/bin/bash OLDDIR=$PWD cd /root/www -twistd --pidfile=/root/twistd.pid web --https=5000 --wsgi app.app -c app/hplumberjack.crt -k app/hplumberjack.key +twistd --pidfile=/root/datalogger.pid web --https=5000 --wsgi app.app -c app/hplumberjack.crt -k app/hplumberjack.key cd $OLDDIR diff --git a/stop.sh b/stop.sh deleted file mode 100644 index 2988ed3..0000000 --- a/stop.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -kill $(cat /root/twistd.pid) -mv /root/twistd.pid /root/twistd.pid.old