diff roundup/scripts/roundup_server.py @ 3111:e0aab0d08265 maint-0.8

fix roundup-server log and PID file paths to be absolute fix initialisation of roundup-server in daemon mode so initialisation errors are visible
author Richard Jones <richard@users.sourceforge.net>
date Sat, 15 Jan 2005 06:53:00 +0000
parents e4bac783c617
children 07f68dfab2c2
line wrap: on
line diff
--- a/roundup/scripts/roundup_server.py	Thu Jan 13 23:11:26 2005 +0000
+++ b/roundup/scripts/roundup_server.py	Sat Jan 15 06:53:00 2005 +0000
@@ -17,7 +17,7 @@
 
 """Command-line script that runs a server over roundup.cgi.client.
 
-$Id: roundup_server.py,v 1.74.2.1 2004-12-22 06:38:08 a1s Exp $
+$Id: roundup_server.py,v 1.74.2.2 2005-01-15 06:53:00 richard Exp $
 """
 __docformat__ = 'restructuredtext'
 
@@ -392,13 +392,13 @@
                 self["TRACKERS_" + option.upper()])))
         return trackers
 
+    def set_logging(self):
+        """Initialise logging to the configured file, if any."""
+        # appending, unbuffered
+        sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0)
+
     def get_server(self):
         """Return HTTP server object to run"""
-        # redirect stdout/stderr to our logfile
-        # this is done early to have following messages go to this logfile
-        if self["LOGFILE"]:
-            # appending, unbuffered
-            sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0)
         # we don't want the cgi module interpreting the command-line args ;)
         sys.argv = sys.argv[:1]
         # preload all trackers unless we are in "debug" mode
@@ -478,6 +478,7 @@
                     (self._svc_display_name_, "\r\nMissing logfile option"))
                 self.ReportServiceStatus(win32service.SERVICE_STOPPED)
                 return
+            config.set_logging()
             self.server = config.get_server()
             self.running = 1
             self.ReportServiceStatus(win32service.SERVICE_RUNNING)
@@ -605,7 +606,7 @@
     os.chdir("/")
     os.umask(0)
 
-    # close off sys.std(in|out|err), redirect to devnull so the file
+    # close off std(in|out|err), redirect to devnull so the file
     # descriptors can't be used again
     devnull = os.open('/dev/null', 0)
     os.dup2(devnull, 0)
@@ -689,6 +690,13 @@
     if port is not undefined:
         config.PORT = port
 
+    if config["LOGFILE"]:
+        config["LOGFILE"] = os.path.abspath(config["LOGFILE"])
+        # switch logging from stderr/stdout to logfile
+        config.set_logging()
+    if config["PIDFILE"]:
+        config["PIDFILE"] = os.path.abspath(config["PIDFILE"])
+
     # fork the server from our parent if a pidfile is specified
     if config["PIDFILE"]:
         if not hasattr(os, 'fork'):

Roundup Issue Tracker: http://roundup-tracker.org/