def server_main(args=sys.argv):
parser = get_server_options_parser()
# sys.argv includes the path of invocation as the first index in the list
# argparse expects just the parameters if we pass a list into parse_args
# so here we get rid of that path parameter and are left with only the args
# from the command line
if args == sys.argv:
args = args[1:]
args = parser.parse_args(args)
HopliteServerSettings.debug = args.debug
app = create_app()
logger.info('Starting Hoplite server on port {}'.format(args.port))
http_server = HTTPServer(WSGIContainer(app))
http_server.listen(args.port)
ioloop = IOLoop.instance()
# This is needed to ensure Ctrl-C kills the server quickly
set_ping(ioloop, timedelta(seconds=2))
try:
ioloop.start()
except:
raise
finally:
# Ensure that the server always closes the socket when it's no longer
# in use
ioloop.stop()
评论列表
文章目录