-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun.py
37 lines (27 loc) · 906 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys
import argparse
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
from twisted.python import log
from web import app
from ircbot import setup
def main(argv):
assert sys.version_info[0] == 3
parser = argparse.ArgumentParser()
parser.add_argument("-p", "--port", type=int, default=8160,
help="port number")
parser.add_argument("-d", "--debug", action="store_true")
parser.add_argument("-c", "--connect", action="store_true")
args = parser.parse_args()
if args.debug:
app.debug = True
log.startLogging(sys.stdout)
wsgiResource = WSGIResource(reactor, reactor.getThreadPool(), app)
site = Site(wsgiResource)
reactor.listenTCP(args.port, site)
if args.connect:
setup()
reactor.run()
if __name__ == "__main__":
main(sys.argv)