main.py 657 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env python
  2. #coding=utf-8
  3. """
  4. demeter web
  5. name:main.py
  6. author:rabin
  7. """
  8. import tornado.ioloop
  9. import tornado.httpserver
  10. from application import *
  11. if __name__ == Demeter.web + ".main":
  12. if settings['debug'] == True:
  13. application.listen(settings['port'])
  14. tornado.ioloop.IOLoop.instance().start()
  15. else:
  16. server = tornado.httpserver.HTTPServer(application, settings['max_buffer_size'])
  17. server.bind(settings['port'])
  18. server.start(settings['process'])
  19. try:
  20. print 'running on port %s' % settings['port']
  21. tornado.ioloop.IOLoop.instance().start()
  22. except KeyboardInterrupt:
  23. tornado.ioloop.IOLoop.instance().stop()