[Zodb-checkins] CVS: ZODB3/zdaemon - sample.conf:1.5 schema.xml:1.6 zdctl.py:1.22 zdoptions.py:1.9 zdrun.py:1.7

Guido van Rossum guido@python.org
Wed, 22 Jan 2003 16:23:00 -0500


Update of /cvs-repository/ZODB3/zdaemon
In directory cvs.zope.org:/tmp/cvs-serv10094/zdaemon

Modified Files:
	sample.conf schema.xml zdctl.py zdoptions.py zdrun.py 
Log Message:
Rename options.zdirectory to options.directory.
Add an <eventlog> section to the runner schema.
Some comment and docstring tweakage.

=== ZODB3/zdaemon/sample.conf 1.4 => 1.5 ===
--- ZODB3/zdaemon/sample.conf:1.4	Tue Jan 21 13:52:19 2003
+++ ZODB3/zdaemon/sample.conf	Wed Jan 22 16:22:56 2003
@@ -13,3 +13,10 @@
   directory	/
   default-to-interactive True
 </runner>
+
+<eventlog>
+  level info
+  <logfile>
+    path /tmp/zdrun.log
+  </logfile>
+</eventlog>


=== ZODB3/zdaemon/schema.xml 1.5 => 1.6 ===
--- ZODB3/zdaemon/schema.xml:1.5	Tue Jan 21 13:52:19 2003
+++ ZODB3/zdaemon/schema.xml	Wed Jan 22 16:22:56 2003
@@ -4,6 +4,8 @@
     Schema for zdctl.py and zdrun.py.
   </description>
 
+  <import package="zLOG"/>
+
   <sectiontype name="runner">
     <key name="python" datatype="existing-path" />
     <key name="zdrun" datatype="existing-path" />
@@ -20,5 +22,7 @@
   </sectiontype>
 
   <section name="*" type="runner" attribute="runner" required="yes" />
+
+  <section name="*" type="eventlog" attribute="eventlog" required="no" />
 
 </schema>


=== ZODB3/zdaemon/zdctl.py 1.21 => 1.22 ===
--- ZODB3/zdaemon/zdctl.py:1.21	Tue Jan 21 13:52:19 2003
+++ ZODB3/zdaemon/zdctl.py	Wed Jan 22 16:22:56 2003
@@ -196,7 +196,7 @@
                 "-d",
                 "-s", self.options.sockname,
                 "-x", ",".join(map(str, self.options.exitcodes)),
-                "-z", self.options.zdirectory,
+                "-z", self.options.directory,
                 ]
             if self.options.forever:
                 args.append("-f")
@@ -316,7 +316,7 @@
         print "sockname:    ", repr(self.options.sockname)
         print "exitcodes:   ", repr(self.options.exitcodes)
         print "user:        ", repr(self.options.user)
-        print "zdirectory:  ", repr(self.options.zdirectory)
+        print "directory:   ", repr(self.options.directory)
 
     def show_python(self):
         version = sys.version.replace("\n", "\n              ")


=== ZODB3/zdaemon/zdoptions.py 1.8 => 1.9 ===
--- ZODB3/zdaemon/zdoptions.py:1.8	Tue Jan 21 13:19:38 2003
+++ ZODB3/zdaemon/zdoptions.py	Wed Jan 22 16:22:56 2003
@@ -251,7 +251,7 @@
         if self.logsectionname:
             self.load_logconf(self.logsectionname)
 
-    def load_logconf(self, sectname="logger"):
+    def load_logconf(self, sectname="eventlog"):
         parts = sectname.split(".")
         obj = self.configroot
         for p in parts:
@@ -287,7 +287,7 @@
         self.add("exitcodes", "runner.exit_codes", "x:", "exit-codes=",
                  list_of_ints, default=[0, 2])
         self.add("user", "runner.user", "u:", "user=")
-        self.add("zdirectory", "runner.directory", "z:", "directory=",
+        self.add("directory", "runner.directory", "z:", "directory=",
                  ZConfig.datatypes.existing_directory, default="/")
 
 


=== ZODB3/zdaemon/zdrun.py 1.6 => 1.7 ===
--- ZODB3/zdaemon/zdrun.py:1.6	Tue Jan 21 13:51:12 2003
+++ ZODB3/zdaemon/zdrun.py	Wed Jan 22 16:22:56 2003
@@ -19,7 +19,7 @@
 Options:
 -C/--configuration URL -- configuration file or URL
 -b/--backoff-limit SECONDS -- set backoff limit to SECONDS (default 10)
--d/--daemon-- run as a proper daemon; fork a subprocess, close files etc.
+-d/--daemon -- run as a proper daemon; fork a subprocess, setsid(), etc.
 -f/--forever -- run forever (by default, exit when backoff limit is exceeded)
 -h/--help -- print this usage message and exit
 -s/--socket-name SOCKET -- Unix socket name for client (default "zdsock")
@@ -89,6 +89,7 @@
 class ZDRunOptions(RunnerOptions):
 
     positional_args_allowed = 1
+    logsectionname = "eventlog"
     program = None
 
     def realize(self, *args, **kwds):
@@ -321,14 +322,14 @@
             os._exit(0)
         # Child
         info("daemonizing the process")
-        if self.options.zdirectory:
+        if self.options.directory:
             try:
-                os.chdir(self.options.zdirectory)
+                os.chdir(self.options.directory)
             except os.error, err:
                 warn("can't chdir into %r: %s" %
-                     (self.options.zdirectory, err))
+                     (self.options.directory, err))
             else:
-                info("set current directory: %r" % self.options.zdirectory)
+                info("set current directory: %r" % self.options.directory)
         os.close(0)
         sys.stdin = sys.__stdin__ = open("/dev/null")
         os.close(1)
@@ -336,6 +337,11 @@
         os.close(2)
         sys.stderr = sys.__stderr__ = open("/dev/null", "w")
         os.setsid()
+        # XXX Stevens, in his Advanced Unix book, section 13.3 (page
+        # 417) also recommends calling umask(0) and closing unused
+        # file descriptors.  In his Network Programming book, he
+        # additionally recommends ignoring SIGHUP and forking again
+        # after the setsid() call, for obscure SVR4 reasons.
 
     mood = 1 # 1: up, 0: down, -1: suicidal
     delay = 0 # If nonzero, delay starting or killing until this time