-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
34 lines (27 loc) · 856 Bytes
/
main.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
import argparse
import os
import traceback
import tornado.ioloop
import tornado.web
from tornado.options import options, parse_command_line
from Ryu import app, settings
async def init():
config = await settings.get_config()
return config
if __name__ == '__main__':
parse_command_line()
app_root = os.path.dirname(__file__)
options.parse_config_file(os.path.join(app_root, "conf/%s/server.conf" % options.env))
# Initialize state and static resources
config = tornado.ioloop.IOLoop.current().run_sync(init)
# Start application
application = app.Application(config, options.port)
# Start eventloop
try:
tornado.ioloop.IOLoop.current().start()
except KeyboardInterrupt:
pass
except Exception:
traceback.print_exc()
finally:
tornado.ioloop.IOLoop.current().stop()