summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c772c80)
raw | patch | inline | side by side (parent: c772c80)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 4 Sep 2002 07:32:55 +0000 (07:32 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Wed, 4 Sep 2002 07:32:55 +0000 (07:32 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1066 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/scripts/roundup_server.py | patch | blob | history |
index b5f635e8aed1758f6e68afefee642dadd06969eb..9179a6ecbd873b68739b64e51c8db319806afb8b 100644 (file)
#
""" HTTP Server that serves roundup.
-$Id: roundup_server.py,v 1.6 2002-08-30 08:33:28 richard Exp $
+$Id: roundup_server.py,v 1.7 2002-09-04 07:32:55 richard Exp $
"""
# python version check
if message:
message = _('Error: %(error)s\n\n')%{'error': message}
print _('''%(message)sUsage:
-roundup-server [-n hostname] [-p port] [name=instance home]*
+roundup-server [-n hostname] [-p port] [-l file] [-d file] [name=instance home]*
-n: sets the host name
-p: sets the port to listen on
+ -l: sets a filename to log to (instead of stdout)
+ -d: daemonize, and write the server's PID to the nominated file
name=instance home
Sets the instance home(s) to use. The name is how the instance is
def run():
hostname = ''
port = 8080
+ pidfile = None
+ logfile = None
try:
# handle the command-line args
try:
- optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:')
+ optlist, args = getopt.getopt(sys.argv[1:], 'n:p:u:d:l:')
except getopt.GetoptError, e:
usage(str(e))
if opt == '-n': hostname = arg
elif opt == '-p': port = int(arg)
elif opt == '-u': user = arg
+ elif opt == '-d': pidfile = arg
+ elif opt == '-l': logfile = arg
elif opt == '-h': usage()
if hasattr(os, 'getuid'):
# we don't want the cgi module interpreting the command-line args ;)
sys.argv = sys.argv[:1]
address = (hostname, port)
+
+ # fork?
+ if pidfile:
+ pid = os.fork()
+ if pid:
+ print 'forking', pid
+ open(pidfile, 'w').write(str(pid))
+ return
+
+ # redirect stdout/stderr
+ if logfile:
+ sys.stdout = sys.stderr = open(logfile, 'a')
+
httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler)
print _('Roundup server started on %(address)s')%locals()
httpd.serve_forever()
#
# $Log: not supported by cvs2svn $
+# Revision 1.6 2002/08/30 08:33:28 richard
+# new CGI frontend support
+#
# Revision 1.5 2002/03/14 23:59:24 richard
# . #517734 ] web header customisation is obscure
#