[Zope3-checkins] SVN: zdaemon/trunk/src/zdaemon/zd Simplified runner state management.

jim cvs-admin at zope.org
Mon Jun 4 19:11:04 UTC 2012


Log message for revision 126588:
  Simplified runner state management.
  

Changed:
  U   zdaemon/trunk/src/zdaemon/zdctl.py
  U   zdaemon/trunk/src/zdaemon/zdoptions.py
  U   zdaemon/trunk/src/zdaemon/zdrun.py

-=-
Modified: zdaemon/trunk/src/zdaemon/zdctl.py
===================================================================
--- zdaemon/trunk/src/zdaemon/zdctl.py	2012-06-04 17:01:22 UTC (rev 126587)
+++ zdaemon/trunk/src/zdaemon/zdctl.py	2012-06-04 19:11:00 UTC (rev 126588)
@@ -444,7 +444,6 @@
         print "umask:       ", oct(umask)
         print "directory:   ", repr(self.options.directory)
         print "logfile:     ", repr(self.options.logfile)
-        print "hang_around: ", repr(self.options.hang_around)
 
     def show_python(self):
         print "Python info:"

Modified: zdaemon/trunk/src/zdaemon/zdoptions.py
===================================================================
--- zdaemon/trunk/src/zdaemon/zdoptions.py	2012-06-04 17:01:22 UTC (rev 126587)
+++ zdaemon/trunk/src/zdaemon/zdoptions.py	2012-06-04 19:11:00 UTC (rev 126588)
@@ -403,7 +403,6 @@
                  default=022)
         self.add("directory", "runner.directory", "z:", "directory=",
                  existing_parent_directory)
-        self.add("hang_around", "runner.hang_around", default=0)
 
     def realize(self, *args, **kwds):
         ZDOptions.realize(self, *args, **kwds)

Modified: zdaemon/trunk/src/zdaemon/zdrun.py
===================================================================
--- zdaemon/trunk/src/zdaemon/zdrun.py	2012-06-04 17:01:22 UTC (rev 126587)
+++ zdaemon/trunk/src/zdaemon/zdrun.py	2012-06-04 19:11:00 UTC (rev 126588)
@@ -382,16 +382,15 @@
         # additionally recommends ignoring SIGHUP and forking again
         # after the setsid() call, for obscure SVR4 reasons.
 
-    mood = 1 # 1: up, 0: down, -1: suicidal
+    should_be_up = True
     delay = 0 # If nonzero, delay starting or killing until this time
     killing = 0 # If true, send SIGKILL when delay expires
     proc = None # Subprocess instance
 
     def runforever(self):
         self.logger.info("daemon manager started")
-        min_mood = not self.options.hang_around
-        while self.mood >= min_mood or self.proc.pid:
-            if self.mood > 0 and not self.proc.pid and not self.delay:
+        while self.should_be_up or self.proc.pid:
+            if self.should_be_up and not self.proc.pid and not self.delay:
                 pid = self.proc.spawn()
                 if not pid:
                     # Can't fork.  Try again later...
@@ -519,7 +518,7 @@
             self.sendreply("Unknown command %r; 'help' for a list" % args[0])
 
     def cmd_start(self, args):
-        self.mood = 1 # Up
+        self.should_be_up = True
         self.backoff = 0
         self.delay = 0
         self.killing = 0
@@ -530,7 +529,7 @@
             self.sendreply("Application already started")
 
     def cmd_stop(self, args):
-        self.mood = 0 # Down
+        self.should_be_up = False
         self.backoff = 0
         self.delay = 0
         self.killing = 0
@@ -543,7 +542,7 @@
             self.sendreply("Application already stopped")
 
     def cmd_restart(self, args):
-        self.mood = 1 # Up
+        self.should_be_up = True
         self.backoff = 0
         self.delay = 0
         self.killing = 0
@@ -556,21 +555,6 @@
             self.proc.spawn()
             self.sendreply("Application started")
 
-    def cmd_exit(self, args):
-        self.mood = -1 # Suicidal
-        self.backoff = 0
-        self.delay = 0
-        self.killing = 0
-        if self.proc.pid:
-            self.proc.kill(signal.SIGTERM)
-            self.sendreply("Sent SIGTERM; will exit later")
-            self.killing = 1
-            self.delay = time.time() + self.options.backofflimit
-        else:
-            self.sendreply("Exiting now")
-            self.logger.info("Exiting")
-            sys.exit(0)
-
     def cmd_kill(self, args):
         if args[1:]:
             try:
@@ -596,7 +580,7 @@
             status = "running"
         self.sendreply("status=%s\n" % status +
                        "now=%r\n" % time.time() +
-                       "mood=%d\n" % self.mood +
+                       "should_be_up=%d\n" % self.should_be_up +
                        "delay=%r\n" % self.delay +
                        "backoff=%r\n" % self.backoff +
                        "lasttime=%r\n" % self.proc.lasttime +



More information about the Zope3-Checkins mailing list