Permalink
Browse files

added support for tornado's command line options

  • Loading branch information...
kumarnitin committed Oct 29, 2012
1 parent 3f1160f commit f328e539c8345a2972a1921d7ee7751560914743
Showing with 19 additions and 15 deletions.
  1. +19 −15 src/redis-live.py
View
@@ -2,6 +2,7 @@
import tornado.ioloop
import tornado.options
+from tornado.options import define, options
import tornado.web
from api.controller.BaseStaticFileHandler import BaseStaticFileHandler
@@ -13,20 +14,23 @@
from api.controller.TopCommandsController import TopCommandsController
from api.controller.TopKeysController import TopKeysController
+if __name__ == "__main__":
+ define("port", default=8888, help="run on the given port", type=int)
+ define("debug", default=0, help="debug mode", type=int)
+ tornado.options.parse_command_line()
-# Bootup
-application = tornado.web.Application([
- (r"/api/servers", ServerListController),
- (r"/api/info", InfoController),
- (r"/api/memory", MemoryController),
- (r"/api/commands", CommandsController),
- (r"/api/topcommands", TopCommandsController),
- (r"/api/topkeys", TopKeysController),
- (r"/(.*)", BaseStaticFileHandler, {"path": "www"})
-], debug="True")
-
+ # Bootup
+ handlers = [
+ (r"/api/servers", ServerListController),
+ (r"/api/info", InfoController),
+ (r"/api/memory", MemoryController),
+ (r"/api/commands", CommandsController),
+ (r"/api/topcommands", TopCommandsController),
+ (r"/api/topkeys", TopKeysController),
+ (r"/(.*)", BaseStaticFileHandler, {"path": "www"})
+ ]
-if __name__ == "__main__":
- tornado.options.parse_command_line()
- application.listen(8888)
- tornado.ioloop.IOLoop.instance().start()
+ server_settings = {'debug': options.debug}
+ application = tornado.web.Application(handlers, **server_settings)
+ application.listen(options.port)
+ tornado.ioloop.IOLoop.instance().start()

0 comments on commit f328e53

Please sign in to comment.