コード例 #1
0
    def run(self):
        http_config = self.config['http']
        https_config = self.config['https']

        wsgi_app = wsgi.WSGIPathInfoDispatcher({'/': self.app})
        cherrypy.server.unsubscribe()
        cherrypy.config.update({'environment': 'production'})

        if https_config['enabled']:
            try:
                bind_addr_https = (https_config['listen'],
                                   https_config['port'])
                server_https = wsgi.WSGIServer(bind_addr=bind_addr_https,
                                               wsgi_app=wsgi_app)
                server_https.ssl_adapter = http_helpers.ssl_adapter(
                    https_config['certificate'], https_config['private_key'])

                ServerAdapter(cherrypy.engine, server_https).subscribe()
                logger.debug(
                    'WSGIServer starting... uid: %s, listen: %s:%s',
                    os.getuid(),
                    bind_addr_https[0],
                    bind_addr_https[1],
                )
            except IOError as e:
                logger.warning("HTTPS server won't start: %s", e)
        else:
            logger.debug('HTTPS server is disabled')

        if http_config['enabled']:
            bind_addr_http = (http_config['listen'], http_config['port'])
            server_http = wsgi.WSGIServer(bind_addr=bind_addr_http,
                                          wsgi_app=wsgi_app)
            ServerAdapter(cherrypy.engine, server_http).subscribe()
            logger.debug(
                'WSGIServer starting... uid: %s, listen: %s:%s',
                os.getuid(),
                bind_addr_http[0],
                bind_addr_http[1],
            )
        else:
            logger.debug('HTTP server is disabled')

        if not http_config['enabled'] and not https_config['enabled']:
            logger.critical('No HTTP/HTTPS server enabled')
            exit()

        list_routes(self.app)

        try:
            cherrypy.engine.start()
            cherrypy.engine.wait(states.EXITING)
        except KeyboardInterrupt:
            logger.warning('Stopping wazo-phoned: KeyboardInterrupt')
            cherrypy.engine.exit()
コード例 #2
0
    def run(self):
        if self.config['profile']:
            app.wsgi_app = ProfilerMiddleware(
                app.wsgi_app, profile_dir=self.config['profile'])

        wsgi_app = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': app})))

        bind_addr = (self.config['listen'], self.config['port'])
        self.server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app)
        self.server.ssl_adapter = http_helpers.ssl_adapter(
            self.config['certificate'], self.config['private_key'])
        logger.debug(
            'WSGIServer starting... uid: %s, listen: %s:%s',
            os.getuid(),
            bind_addr[0],
            bind_addr[1],
        )
        for route in http_helpers.list_routes(app):
            logger.debug(route)

        try:
            self.server.start()
        except KeyboardInterrupt:
            logger.warning('Stopping wazo-confd: KeyboardInterrupt')
            self.server.stop()
コード例 #3
0
    def run(self):
        bind_addr = (self.config['listen'], self.config['port'])

        wsgi_app = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': app})))
        self.server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app)
        if self.config['certificate'] and self.config['private_key']:
            logger.warning(
                'Using service SSL configuration is deprecated. Please use NGINX instead.'
            )
            self.server.ssl_adapter = http_helpers.ssl_adapter(
                self.config['certificate'], self.config['private_key'])

        logger.debug(
            'WSGIServer starting... uid: %s, listen: %s:%s',
            os.getuid(),
            bind_addr[0],
            bind_addr[1],
        )
        for route in http_helpers.list_routes(app):
            logger.debug(route)

        try:
            self.server.start()
        except KeyboardInterrupt:
            self.server.stop()
コード例 #4
0
ファイル: http_server.py プロジェクト: fossabot/wazo-auth
    def run(self):
        bind_addr = (self.config['https']['listen'], self.config['https']['port'])

        wsgi_app = wsgi.WSGIPathInfoDispatcher({'/': app})
        self.server = wsgi.WSGIServer(
            bind_addr=bind_addr,
            wsgi_app=wsgi_app,
            numthreads=self.config['max_threads'],
        )
        self.server.ssl_adapter = http_helpers.ssl_adapter(
            self.config['https']['certificate'], self.config['https']['private_key']
        )
        logger.debug(
            'WSGIServer starting... uid: %s, listen: %s:%s',
            os.getuid(),
            bind_addr[0],
            bind_addr[1],
        )
        for route in http_helpers.list_routes(app):
            logger.debug(route)

        try:
            self.server.start()
        except KeyboardInterrupt:
            self.server.stop()
コード例 #5
0
    def __init__(self, config, root_worker):
        self._executor = ThreadPoolExecutor(
            max_workers=10)  # Make it configurable
        self._xivo_uuid = config.get('uuid')
        self._listen_addr = config['rest_api']['https']['listen']
        self._listen_port = config['rest_api']['https']['port']
        self._cors_config = config['rest_api']['cors']
        self._ssl_cert_file = config['rest_api']['https']['certificate']
        ssl_key_file = config['rest_api']['https']['private_key']
        self._consul_config = config['consul']
        self._service_discovery_config = config['service_discovery']
        self._bus_config = config['bus']

        bind_addr = (self._listen_addr, self._listen_port)
        self._publisher = bus.StatusPublisher.from_config(config)
        plugin_service = service.PluginService.from_config(
            config, self._publisher, root_worker, self._executor)

        flask_app = http.new_app(config, plugin_service=plugin_service)
        flask_app.after_request(http_helpers.log_request)
        wsgi.WSGIServer.ssl_adapter = http_helpers.ssl_adapter(
            self._ssl_cert_file, ssl_key_file)
        wsgi_app = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': flask_app})))
        self._server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app)
        for route in http_helpers.list_routes(flask_app):
            logger.debug(route)
コード例 #6
0
ファイル: rest_api.py プロジェクト: sileht/xivo-ctid-ng
    def run(self):
        wsgi_app_https = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': app})))
        wsgi_app_http = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': adapter_app})))
        cherrypy.server.unsubscribe()
        cherrypy.config.update({'environment': 'production'})

        bind_addr = (self.config['listen'], self.config['port'])

        server_https = wsgi.WSGIServer(bind_addr=bind_addr,
                                       wsgi_app=wsgi_app_https)
        server_https.ssl_adapter = http_helpers.ssl_adapter(
            self.config['certificate'], self.config['private_key'])
        ServerAdapter(cherrypy.engine, server_https).subscribe()
        logger.debug('WSGIServer starting... uid: %s, listen: %s:%s',
                     os.getuid(), bind_addr[0], bind_addr[1])

        for route in http_helpers.list_routes(app):
            logger.debug(route)

        if self.adapter_config['enabled']:
            bind_addr = (self.adapter_config['listen'],
                         self.adapter_config['port'])
            server_adapter = wsgi.WSGIServer(bind_addr=bind_addr,
                                             wsgi_app=wsgi_app_http)
            ServerAdapter(cherrypy.engine, server_adapter).subscribe()
            logger.debug('WSGIServer starting... uid: %s, listen: %s:%s',
                         os.getuid(), bind_addr[0], bind_addr[1])

            for route in http_helpers.list_routes(adapter_app):
                logger.debug(route)

        else:
            logger.debug('Adapter server is disabled')

        try:
            cherrypy.engine.start()
            cherrypy.engine.wait(states.EXITING)
        except KeyboardInterrupt:
            logger.warning('Stopping xivo-ctid-ng: KeyboardInterrupt')
            cherrypy.engine.exit()
コード例 #7
0
    def run(self, handler):
        from cheroot import wsgi
        from cheroot.ssl.pyopenssl import pyOpenSSLAdapter

        server = wsgi.WSGIServer((self.host, self.port), handler)
        server.ssl_adapter = pyOpenSSLAdapter(certificate="ucmpcs.org.crt",
                                              private_key="ucmpcs.org.key")

        #try:
        print "Starting secure web application server using CherryPy..."
        server.start()
コード例 #8
0
 def __init__(self, config, main_thread_proxy):
     app = Flask('xivo_ctid')
     http_helpers.add_logger(app, logger)
     app.after_request(http_helpers.log_request)
     app.secret_key = os.urandom(24)
     self.load_cors(app, config)
     api = Api(app, prefix='/{}'.format(self.VERSION))
     self._add_resources(api, main_thread_proxy)
     bind_addr = (config['http']['listen'], config['http']['port'])
     wsgi_app = wsgi.WSGIPathInfoDispatcher({'/': app})
     self._server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app)
コード例 #9
0
    def run(self):
        config = self._config['https']
        bind_addr = (config['listen'], config['port'])

        wsgi_app = ReverseProxied(ProxyFix(self._app))
        server = wsgi.WSGIServer(bind_addr, wsgi_app)
        server.ssl_adapter = http_helpers.ssl_adapter(config['certificate'],
                                                      config['private_key'])
        try:
            server.start()
        finally:
            server.stop()
コード例 #10
0
    def run(self):
        bind_addr = (self._config['listen'], self._config['port'])

        wsgi_app = ReverseProxied(ProxyFix(self._app))
        server = wsgi.WSGIServer(bind_addr, wsgi_app)
        if self._config['certificate'] and self._config['private_key']:
            logger.warning(
                'Using service SSL configuration is deprecated. Please use NGINX instead.'
            )
            server.ssl_adapter = http_helpers.ssl_adapter(
                self._config['certificate'], self._config['private_key'])
        try:
            server.start()
        finally:
            server.stop()
コード例 #11
0
    def run(self):
        self.api.init_app(self.app)

        https_config = self.config['https']

        bind_addr = (https_config['listen'], https_config['port'])

        wsgi_app = ReverseProxied(
            ProxyFix(wsgi.WSGIPathInfoDispatcher({'/': self.app})))
        server = wsgi.WSGIServer(bind_addr=bind_addr, wsgi_app=wsgi_app)
        server.ssl_adapter = http_helpers.ssl_adapter(
            https_config['certificate'], https_config['private_key'])
        logger.debug('WSGIServer starting... uid: %s, listen: %s:%s',
                     os.getuid(), bind_addr[0], bind_addr[1])
        for route in http_helpers.list_routes(self.app):
            logger.debug(route)

        try:
            server.start()
        finally:
            server.stop()
コード例 #12
0
 def _get_wsgi_server(self, host, port):
     return wsgi.WSGIServer((host, port), wsgi_app=self.dispatcher)