Skip to content

Commit 1fb137f

Browse files
author
Richard Jones
committed
fix roundup-server log and PID file paths to be absolute
fix initialisation of roundup-server in daemon mode so initialisation errors are visible
1 parent 32973bb commit 1fb137f

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

CHANGES.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2005-01-?? 0.8.0
5+
Fixed:
6+
- fix roundup-server log and PID file paths to be absolute
7+
- fix initialisation of roundup-server in daemon mode so initialisation
8+
errors are visible
9+
10+
411
2005-01-13 0.8.0b2
512
Fixed:
613
- note about how to run roundup demo in Windows (sf bug 1082090)

roundup/scripts/roundup_server.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"""Command-line script that runs a server over roundup.cgi.client.
1919
20-
$Id: roundup_server.py,v 1.74.2.1 2004-12-22 06:38:08 a1s Exp $
20+
$Id: roundup_server.py,v 1.74.2.2 2005-01-15 06:53:00 richard Exp $
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

@@ -392,13 +392,13 @@ def trackers(self):
392392
self["TRACKERS_" + option.upper()])))
393393
return trackers
394394

395+
def set_logging(self):
396+
"""Initialise logging to the configured file, if any."""
397+
# appending, unbuffered
398+
sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0)
399+
395400
def get_server(self):
396401
"""Return HTTP server object to run"""
397-
# redirect stdout/stderr to our logfile
398-
# this is done early to have following messages go to this logfile
399-
if self["LOGFILE"]:
400-
# appending, unbuffered
401-
sys.stdout = sys.stderr = open(self["LOGFILE"], 'a', 0)
402402
# we don't want the cgi module interpreting the command-line args ;)
403403
sys.argv = sys.argv[:1]
404404
# preload all trackers unless we are in "debug" mode
@@ -478,6 +478,7 @@ def SvcDoRun(self):
478478
(self._svc_display_name_, "\r\nMissing logfile option"))
479479
self.ReportServiceStatus(win32service.SERVICE_STOPPED)
480480
return
481+
config.set_logging()
481482
self.server = config.get_server()
482483
self.running = 1
483484
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
@@ -605,7 +606,7 @@ def daemonize(pidfile):
605606
os.chdir("/")
606607
os.umask(0)
607608

608-
# close off sys.std(in|out|err), redirect to devnull so the file
609+
# close off std(in|out|err), redirect to devnull so the file
609610
# descriptors can't be used again
610611
devnull = os.open('/dev/null', 0)
611612
os.dup2(devnull, 0)
@@ -689,6 +690,13 @@ def run(port=undefined, success_message=None):
689690
if port is not undefined:
690691
config.PORT = port
691692

693+
if config["LOGFILE"]:
694+
config["LOGFILE"] = os.path.abspath(config["LOGFILE"])
695+
# switch logging from stderr/stdout to logfile
696+
config.set_logging()
697+
if config["PIDFILE"]:
698+
config["PIDFILE"] = os.path.abspath(config["PIDFILE"])
699+
692700
# fork the server from our parent if a pidfile is specified
693701
if config["PIDFILE"]:
694702
if not hasattr(os, 'fork'):

0 commit comments

Comments
 (0)