示例#1
0
文件: app.py 项目: wujcheng/pritunl
def _run_wsgi(restart=False):
    global app_server

    logger.info('Starting server', 'app')

    app_server = limiter.CherryPyWSGIServerLimited(
        (settings.conf.bind_addr, settings.app.server_port),
        app,
        request_queue_size=settings.app.request_queue_size,
        server_name=APP_NAME,
    )
    app_server.shutdown_timeout = 1

    if settings.app.server_ssl:
        setup_server_cert()

        server_cert_path, server_chain_path, server_key_path, \
            server_dh_path = utils.write_server_cert(
                settings.app.server_cert,
                settings.app.server_key,
                settings.app.server_dh_params,
                settings.app.acme_domain,
            )

        app_server.ssl_adapter = SSLAdapter(
            server_cert_path,
            server_key_path,
            server_chain_path,
            server_dh_path,
        )

    if not restart:
        settings.local.server_ready.set()
        settings.local.server_start.wait()

    _watch_event.set()

    try:
        app_server.start()
    except (KeyboardInterrupt, SystemExit):
        pass
    except ServerRestart:
        _watch_event.clear()
        logger.info('Server restarting...', 'app')
        return _run_wsgi(True)
    except:
        logger.exception('Server error occurred', 'app')
        raise
示例#2
0
文件: app.py 项目: gergnz/pritunl
def _run_redirect_wsgi():
    logger.info('Starting redirect server', 'app')

    server = limiter.CherryPyWSGIServerLimited(
        (settings.conf.bind_addr, 80),
        redirect_app,
        server_name=APP_NAME,
    )

    try:
        server.start()
    except (KeyboardInterrupt, SystemExit):
        pass
    except:
        logger.exception('Redirect server error occurred', 'app')
        raise
示例#3
0
文件: app.py 项目: gergnz/pritunl
def _run_wsgi(restart=False):
    global app_server

    logger.info('Starting server', 'app')

    app_server = limiter.CherryPyWSGIServerLimited(
        (settings.conf.bind_addr, settings.app.server_port),
        app,
        request_queue_size=settings.app.request_queue_size,
        server_name=APP_NAME,
    )
    app_server.shutdown_timeout = 1

    if settings.app.server_ssl:
        utils.write_server_cert()

        server_cert_path = os.path.join(settings.conf.temp_path,
                                        SERVER_CERT_NAME)
        server_key_path = os.path.join(settings.conf.temp_path,
                                       SERVER_KEY_NAME)
        app_server.ssl_adapter = SSLAdapter(
            server_cert_path,
            server_key_path,
        )

    if not restart:
        settings.local.server_ready.set()
        settings.local.server_start.wait()

    try:
        app_server.start()
    except (KeyboardInterrupt, SystemExit):
        pass
    except ServerRestart:
        logger.info('Server restarting...', 'app')
        return _run_wsgi(True)
    except:
        logger.exception('Server error occurred', 'app')
        raise
示例#4
0
def _run_wsgi():
    logger.info('Starting server', 'app')

    server = limiter.CherryPyWSGIServerLimited(
        (settings.conf.bind_addr, settings.conf.port),
        app,
        request_queue_size=settings.app.request_queue_size,
        server_name=wsgiserver.CherryPyWSGIServer.version)

    if settings.conf.ssl:
        server.ssl_adapter = SSLAdapter(settings.conf.server_cert_path,
                                        settings.conf.server_key_path)

    settings.local.server_ready.set()
    settings.local.server_start.wait()

    try:
        server.start()
    except (KeyboardInterrupt, SystemExit):
        pass
    except:
        logger.exception('Server error occurred', 'app')
        raise