Sfoglia il codice sorgente

优化shutdown脚本

James Iter 8 anni fa
parent
commit
136dc4bd18
2 ha cambiato i file con 12 aggiunte e 7 eliminazioni
  1. 11 6
      shutdown.sh
  2. 1 1
      startup.sh

+ 11 - 6
shutdown.sh

@@ -10,19 +10,24 @@
 
 kill `cat /run/jimv/jimvc.pid`
 
-sleep 2
+sleep 1
 
 # 服务结束后,/run/jimv/jimvc.pid 文件会被 gunicorn 自动清除。如果该文件还存在,则表示服务依然活着。
 # 在执行本脚本 2 秒后,若服务任然活着,则强制结束。
 if [ -f '/run/jimv/jimvc.pid' ]; then
+    sleep 1
 
-    kill -9 `cat /run/jimv/jimvc.pid`
-    rm -f /run/jimv/jimvc.pid
-    echo 'JimV-C is forced to terminate.';
+    if [ -f '/run/jimv/jimvc.pid' ]; then
 
-else
+        kill -9 `cat /run/jimv/jimvc.pid`
+        rm -f /run/jimv/jimvc.pid
+        echo 'JimV-C is forced to terminate.';
+        exit 1
 
-    echo 'JimV-C stopped.';
+    fi
+fi
 
+if [ ! -e '/run/jimv/jimvc.pid' ]; then
+    echo 'JimV-C stopped.';
 fi
 

+ 1 - 1
startup.sh

@@ -20,7 +20,7 @@ if [ `id -u` -eq 0 ]; then
 
     su - www -c "cd ~/sites/JimV-C; gunicorn -c gunicorn_config.py main:app"
 
-elif [ `whoami` -eq 'www' ]; then
+elif [ `whoami` = 'www' ]; then
 
     cd ~/sites/JimV-C; gunicorn -c gunicorn_config.py main:app