changeset 1878:7a07f232e7cb

misc (sat.sh): exec + better stop: - use exec to launch twistd which is specially useful in foreground mode, so signals and other stuff are handled correctly - sat.sh stop now wait until the backend is actually stopped before exiting (before it was just sending the signal and leaving)
author Goffi <goffi@goffi.org>
date Fri, 04 Mar 2016 23:24:06 +0100
parents a97db84c048d
children b43ee22eac98
files src/sat.sh
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/sat.sh	Fri Mar 04 11:22:41 2016 +0100
+++ b/src/sat.sh	Fri Mar 04 23:24:06 2016 +0100
@@ -9,8 +9,12 @@
     if [ -f $1 ]; then
         PID=`cat $1`
         if ps -p $PID > /dev/null; then
-            echo "Terminating $2... "
+            printf  "Terminating $2... "
             kill $PID
+            while ps -p $PID > /dev/null; do
+                sleep 0.2
+            done
+            printf "OK\n"
         else
             echo "No running process of ID $PID... removing PID file"
             rm -f $1
@@ -99,4 +103,4 @@
     mkdir $log_dir
 fi
 
-twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE
+exec twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE