summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: baed603)
raw | patch | inline | side by side (parent: baed603)
author | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 24 Jul 2001 01:07:59 +0000 (01:07 +0000) | ||
committer | richard <richard@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Tue, 24 Jul 2001 01:07:59 +0000 (01:07 +0000) |
out-of-the-box.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@65 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@65 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup-server | patch | blob | history |
diff --git a/roundup-server b/roundup-server
index c67f197ac3645dcf19c523b13197c3529382eacb..d6a03e0eb0eeeb9807cf4a5ad4b9fa3a3f12d98b 100755 (executable)
--- a/roundup-server
+++ b/roundup-server
Stolen from CGIHTTPServer
-$Id: roundup-server,v 1.4 2001-07-23 10:31:45 richard Exp $
+$Id: roundup-server,v 1.5 2001-07-24 01:07:59 richard Exp $
"""
import sys
__all__ = ["RoundupRequestHandler"]
-import os, urllib, StringIO, traceback, cgi, binascii, string
+import os, urllib, StringIO, traceback, cgi, binascii, string, getopt
import BaseHTTPServer
import SimpleHTTPServer
class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ ROUNDUP_INSTANCE_HOMES = ROUNDUP_INSTANCE_HOMES
def send_head(self):
"""Version of send_head that support CGI scripts"""
# TODO: actually do the HEAD ...
raise ValueError, 'No instance specified'
l_path = string.split(rest, '/')
instance = urllib.unquote(l_path[1])
- if ROUNDUP_INSTANCE_HOMES.has_key(instance):
- instance_home = ROUNDUP_INSTANCE_HOMES[instance]
+ if self.ROUNDUP_INSTANCE_HOMES.has_key(instance):
+ instance_home = self.ROUNDUP_INSTANCE_HOMES[instance]
module_path, instance = os.path.split(instance_home)
sys.path.insert(0, module_path)
try:
nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
return nobody
-if __name__ == '__main__':
- # TODO make this configurable again? command-line seems ok to me...
- address = ('', 8080)
+def usage(message=''):
+ if message: message = 'Error: %s\n'%message
+ print '''%sUsage:
+roundup-server [-n hostname] [-p port] [name=instance home]*
+
+ -n: sets the host name
+ -p: sets the port to listen on
+
+ name=instance home
+ Sets the instance home(s) to use. The name is how the instance is
+ identified in the URL (it's the first part of the URL path). The
+ instance home is the directory that was identified when you did
+ "roundup-admin init". You may specify any number of these name=home
+ pairs on the command-line. For convenience, you may edit the
+ ROUNDUP_INSTANCE_HOMES variable in the roundup-server file instead.
+'''%message
+ sys.exit(0)
+
+def main():
+ hostname = ''
+ port = 8080
+ try:
+ # handle the command-line args
+ optlist, args = getopt.getopt(sys.argv[1:], 'n:p:')
+ for (opt, arg) in optlist:
+ if opt == '-n': hostname = arg
+ elif opt == '-p': port = int(arg)
+ elif opt == '-h': usage()
+
+ # handle instance specs
+ if args:
+ d = {}
+ for arg in args:
+ name, home = string.split(arg, '=')
+ d[name] = home
+ RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d
+ except:
+ type, value = sys.exc_info()[:2]
+ usage('%s: %s'%(type, value))
+
+ # we don't want the cgi module interpreting the command-line args ;)
+ sys.argv = sys.argv[:1]
+ address = (hostname, port)
httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler)
print 'Roundup server started on', address
httpd.serve_forever()
+if __name__ == '__main__':
+ main()
+
#
# $Log: not supported by cvs2svn $
+# Revision 1.4 2001/07/23 10:31:45 richard
+# disabled the reloading until it can be done properly
+#
# Revision 1.3 2001/07/23 08:53:44 richard
# Fixed the ROUNDUPS decl in roundup-server
# Move the installation notes to INSTALL