瀏覽代碼

Fixing stale pidfile issue when docker dies abruptly
Signed-off-by: Mike Leone <mleone896@gmail.com>

fixing indent

Signed-off-by: Mike Leone <mleone896@gmail.com>

Mike Leone 10 年之前
父節點
當前提交
05d04843e6
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      contrib/init/sysvinit-redhat/docker

+ 9 - 0
contrib/init/sysvinit-redhat/docker

@@ -43,6 +43,8 @@ prestart() {
 start() {
 start() {
     [ -x $exec ] || exit 5
     [ -x $exec ] || exit 5
 
 
+    check_for_cleanup
+
     if ! [ -f $pidfile ]; then
     if ! [ -f $pidfile ]; then
         prestart
         prestart
         printf "Starting $prog:\t"
         printf "Starting $prog:\t"
@@ -97,6 +99,13 @@ rh_status_q() {
     rh_status >/dev/null 2>&1
     rh_status >/dev/null 2>&1
 }
 }
 
 
+
+check_for_cleanup() {
+    if [ -f ${pidfile} ]; then
+        /bin/ps -fp $(cat ${pidfile}) > /dev/null || rm ${pidfile}
+    fi
+}
+
 case "$1" in
 case "$1" in
     start)
     start)
         rh_status_q && exit 0
         rh_status_q && exit 0