main.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:hoplite 作者: ni 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号