예제 #1
0
 def run_server(self):
     """
     run server for api
     """
     if not ENABLE_SERVER:
         logger.info('server not enabled, exit')
         return
     app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED)
예제 #2
0
    def run_server(self):
        """
        run server for api
        """
        if not ENABLE_SERVER:
            logger.info('server not enabled, exit')
            return
        if IS_PROD:
            if APP_PROD_METHOD == APP_PROD_METHOD_GEVENT:
                try:
                    from gevent.pywsgi import WSGIServer
                except ImportError as e:
                    logger.exception(e)
                else:
                    http_server = WSGIServer((API_HOST, API_PORT), app)
                    http_server.serve_forever()

            elif APP_PROD_METHOD == APP_PROD_METHOD_TORNADO:
                try:
                    from tornado.wsgi import WSGIContainer
                    from tornado.httpserver import HTTPServer
                    from tornado.ioloop import IOLoop
                except ImportError as e:
                    logger.exception(e)
                else:
                    http_server = HTTPServer(WSGIContainer(app))
                    http_server.listen(API_PORT)
                    IOLoop.instance().start()

            elif APP_PROD_METHOD == APP_PROD_METHOD_MEINHELD:
                try:
                    import meinheld
                except ImportError as e:
                    logger.exception(e)
                else:
                    meinheld.listen((API_HOST, API_PORT))
                    meinheld.run(app)

            else:
                logger.error("unsupported APP_PROD_METHOD")
                return
        else:
            app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED)
예제 #3
0
 def run_server():
     app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED)
예제 #4
0
 def run_server(self):
     ''' 运行接口模块 server '''
     if not ENABLE_SERVER:
         logger.info(f'server not enabled, exit')
         return
     app.run(host=API_HOST, port=API_PORT, threaded=API_THREADED)