]>
jfr.im git - irc/quakenet/qwebirc.git/blob - run.py
2 # this entire thing is a hack
5 from twisted
.scripts
.twistd
import run
6 from optparse
import OptionParser
9 def run_twistd(args1
=None, args2
=None):
13 args
.append("qwebirc")
19 def help_reactors(*args
):
20 run_twistd(["--help-reactors"])
23 DEFAULT_REACTOR
= "select" if os
.name
== "nt" else "poll"
25 parser
= OptionParser()
26 parser
.add_option("-n", "--no-daemon", help="Don't run in the background.", action
="store_false", dest
="daemonise", default
=True)
27 parser
.add_option("--help-reactors", help="Display a list of reactor names.", action
="callback", callback
=help_reactors
)
28 parser
.add_option("-b", "--debug", help="Run in the Python Debugger.", action
="store_true", dest
="debug", default
=False)
29 parser
.add_option("-r", "--reactor", help="Which reactor to use (see --help-reactors for a list).", dest
="reactor", default
=DEFAULT_REACTOR
)
30 parser
.add_option("-p", "--port", help="Port to start the server on.", type="int", dest
="port", default
=DEFAULT_PORT
)
31 parser
.add_option("-l", "--logfile", help="Path to twisted log file.", dest
="logfile")
32 parser
.add_option("-c", "--clf", help="Path to web CLF (Combined Log Format) log file.", dest
="clogfile")
33 (options
, args
) = parser
.parse_args()
37 if not options
.daemonise
:
41 args1
+=["--reactor", options
.reactor
]
43 args
+=["--logfile", options
.logfile
]
45 args2
+=["--port", options
.port
]
47 args2
+=["--logfile", options
.clogfile
]
49 run_twistd(args1
, args2
)