|
2 | 2 |
|
3 | 3 | import tornado.ioloop
|
4 | 4 | import tornado.options
|
| 5 | +from tornado.options import define, options |
5 | 6 | import tornado.web
|
6 | 7 |
|
7 | 8 | from api.controller.BaseStaticFileHandler import BaseStaticFileHandler
|
|
13 | 14 | from api.controller.TopCommandsController import TopCommandsController
|
14 | 15 | from api.controller.TopKeysController import TopKeysController
|
15 | 16 |
|
| 17 | +if __name__ == "__main__": |
| 18 | + define("port", default=8888, help="run on the given port", type=int) |
| 19 | + define("debug", default=0, help="debug mode", type=int) |
| 20 | + tornado.options.parse_command_line() |
16 | 21 |
|
17 |
| -# Bootup |
18 |
| -application = tornado.web.Application([ |
19 |
| - (r"/api/servers", ServerListController), |
20 |
| - (r"/api/info", InfoController), |
21 |
| - (r"/api/memory", MemoryController), |
22 |
| - (r"/api/commands", CommandsController), |
23 |
| - (r"/api/topcommands", TopCommandsController), |
24 |
| - (r"/api/topkeys", TopKeysController), |
25 |
| - (r"/(.*)", BaseStaticFileHandler, {"path": "www"}) |
26 |
| -], debug="True") |
27 |
| - |
| 22 | + # Bootup |
| 23 | + handlers = [ |
| 24 | + (r"/api/servers", ServerListController), |
| 25 | + (r"/api/info", InfoController), |
| 26 | + (r"/api/memory", MemoryController), |
| 27 | + (r"/api/commands", CommandsController), |
| 28 | + (r"/api/topcommands", TopCommandsController), |
| 29 | + (r"/api/topkeys", TopKeysController), |
| 30 | + (r"/(.*)", BaseStaticFileHandler, {"path": "www"}) |
| 31 | + ] |
28 | 32 |
|
29 |
| -if __name__ == "__main__": |
30 |
| - tornado.options.parse_command_line() |
31 |
| - application.listen(8888) |
32 |
| - tornado.ioloop.IOLoop.instance().start() |
| 33 | + server_settings = {'debug': options.debug} |
| 34 | + application = tornado.web.Application(handlers, **server_settings) |
| 35 | + application.listen(options.port) |
| 36 | + tornado.ioloop.IOLoop.instance().start() |
0 commit comments