TokyoTyrantで、"Existing process:.."と出て起動しない場合の対処法

$ diff /etc/init.d/ttservd_org  /etc/init.d/ttservd -u
--- /etc/init.d/ttservd_org     2011-11-10 15:30:53.000000000 +0900
+++ /etc/init.d/ttservd 2011-11-10 15:33:34.000000000 +0900
@@ -47,9 +47,15 @@
     retval=1
   elif [ -f "$pidfile" ] ; then
     pid=`cat "$pidfile"`
-    printf 'Existing process: %d\n' "$pid"
-    retval=1
-  else
+    if (ps -e | awk '{print $1}' | grep $pid > /dev/null); then
+      printf 'Existing process: %d\n' "$pid"
+      retval=1
+    else
+      rm -f $pidfile
+    fi
+  fi
+
+  if [ $retval -eq 0 ] ; then
     if [ -n "$maxcon" ] ; then
       ulimit -n "$maxcon" >/dev/null 2>&1
     fi
Enjoy!
カテゴリ: