def main(): models.init_db_data() tornado.options.parse_command_line() application = Application() application.listen(options.port) if options.debug:debug_str = "in debug mode" else:debug_str = "in production mode" print("running senguo.cc {0} @ {1}...".format(debug_str,options.port)) # print("garbage collector: collected %d objecs"%gc.collect()) tornado.ioloop.IOLoop.instance().start()
def stop_loop(): now = time.time() if now < deadline: io_loop.add_timeout(now + 1, stop_loop) else: io_loop.stop() stop_loop() if __name__ == "__main__": # 等待supervisor发送进程结束信号 signal.signal(signal.SIGTERM, sig_handler) signal.signal(signal.SIGINT, sig_handler) models.init_db_data() models_statistics.init_db_data() tornado.options.parse_command_line() app = Application() application = tornado.httpserver.HTTPServer(app, xheaders=True) application.listen(options.port) if options.debug == 1: debug_str = "in debug mode" elif options.debug == 2: print("run test success, exiting...") sys.exit(0) else: debug_str = "in production mode" print("running peihuo.senguo.cc {0} @ {1}...".format( debug_str, options.port)) tornado.ioloop.IOLoop.instance().start()