]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
startstop_node.py: when restarting, tolerate a stale pid too
authorBrian Warner <warner@allmydata.com>
Thu, 26 Feb 2009 02:52:45 +0000 (19:52 -0700)
committerBrian Warner <warner@allmydata.com>
Thu, 26 Feb 2009 02:52:45 +0000 (19:52 -0700)
src/allmydata/scripts/startstop_node.py

index a6f4e239caa27978f8d04c028e5a546be7ee0163..3cfc0845f2c16222af34591b81b332523ef6f5a6 100644 (file)
@@ -111,6 +111,8 @@ def do_stop(basedir, out=sys.stdout, err=sys.stderr):
     pidfile = os.path.join(basedir, "twistd.pid")
     if not os.path.exists(pidfile):
         print >>err, "%s does not look like a running node directory (no twistd.pid)" % basedir
+        # we define rc=2 to mean "nothing is running, but it wasn't me who
+        # stopped it"
         return 2
     pid = open(pidfile, "r").read()
     pid = int(pid)
@@ -125,7 +127,7 @@ def do_stop(basedir, out=sys.stdout, err=sys.stderr):
             print oserr.strerror
             # the process didn't exist, so wipe the pid file
             os.remove(pidfile)
-            return 1
+            return 2
         else:
             raise
     try:
@@ -157,6 +159,7 @@ def do_stop(basedir, out=sys.stdout, err=sys.stderr):
                       (pid, (time.time() - start))
                 wait = 10
         time.sleep(1)
+    # we define rc=1 to mean "I think something is still running, sorry"
     return 1
 
 def start(config, stdout, stderr):