]> jfr.im git - irc/quakenet/qwebirc.git/blame - run.py
Set default HTTP timeout to 60 seconds.
[irc/quakenet/qwebirc.git] / run.py
CommitLineData
8b8ebb78
CP
1#!/usr/bin/env python
2# this entire thing is a hack
3DEFAULT_PORT = 9090
4
5from twisted.scripts.twistd import run
6from optparse import OptionParser
7import sys, os
8
9def run_twistd(args1=None, args2=None):
10 args = [sys.argv[0]]
11 if args1 is not None:
12 args.extend(args1)
13 args.append("qwebirc")
14 if args2 is not None:
15 args.extend(args2)
16 sys.argv = args
17 run()
18
19def help_reactors(*args):
20 run_twistd(["--help-reactors"])
21 sys.exit(1)
22
23DEFAULT_REACTOR = "select" if os.name == "nt" else "poll"
24
25parser = OptionParser()
26parser.add_option("-n", "--no-daemon", help="Don't run in the background.", action="store_false", dest="daemonise", default=True)
27parser.add_option("--help-reactors", help="Display a list of reactor names.", action="callback", callback=help_reactors)
28parser.add_option("-b", "--debug", help="Run in the Python Debugger.", action="store_true", dest="debug", default=False)
0f3c92dc 29parser.add_option("-t", "--tracebacks", help="Display tracebacks in error pages (this reveals a LOT of information, do NOT use in production!)", action="store_true", dest="tracebacks", default=False)
8b8ebb78
CP
30parser.add_option("-r", "--reactor", help="Which reactor to use (see --help-reactors for a list).", dest="reactor", default=DEFAULT_REACTOR)
31parser.add_option("-p", "--port", help="Port to start the server on.", type="int", dest="port", default=DEFAULT_PORT)
32parser.add_option("-l", "--logfile", help="Path to twisted log file.", dest="logfile")
33parser.add_option("-c", "--clf", help="Path to web CLF (Combined Log Format) log file.", dest="clogfile")
34(options, args) = parser.parse_args()
35
36args1, args2 = [], []
37
38if not options.daemonise:
39 args1.append("-n")
40if options.debug:
41 args1.append("-b")
42args1+=["--reactor", options.reactor]
43if options.logfile:
44 args+=["--logfile", options.logfile]
45
46args2+=["--port", options.port]
0f3c92dc
CP
47if not options.tracebacks:
48 args2.append("-n")
8b8ebb78
CP
49if options.clogfile:
50 args2+=["--logfile", options.clogfile]
0f3c92dc 51
8b8ebb78 52run_twistd(args1, args2)