예제 #1
0
def start_server(options):
    """
    Start CherryPy server
    """
    from desktop.lib.wsgiserver import CherryPyWSGIServer as Server
    from django.core.handlers.wsgi import WSGIHandler
    # Translogger wraps a WSGI app with Apache-style combined logging.
    server = Server(
        (options['host'], int(options['port'])),
        WSGIHandler(),
        int(options['threads']), 
        options['server_name']
    )
    if options['ssl_certificate'] and options['ssl_private_key']:
        server.ssl_certificate = options['ssl_certificate']
        server.ssl_private_key = options['ssl_private_key']
        server.ssl_cipher_list = options['ssl_cipher_list']

        ssl_password = conf.get_ssl_password()
        if ssl_password:
            server.ssl_password_cb = lambda *unused: ssl_password

    try:
        server.bind_server()
        drop_privileges_if_necessary(options)
        server.listen_and_loop()
    except KeyboardInterrupt:
        server.stop()
예제 #2
0
def start_server(options):
    """
    Start CherryPy server
    """
    from desktop.lib.wsgiserver import CherryPyWSGIServer as Server
    from desktop.lib.wsgiserver import SSLConnection
    from django.core.handlers.wsgi import WSGIHandler
    # Translogger wraps a WSGI app with Apache-style combined logging.
    server = Server((options['host'], int(options['port'])), WSGIHandler(),
                    int(options['threads']), options['server_name'])
    if options['ssl_certificate'] and options['ssl_private_key']:
        server.ssl_certificate = options['ssl_certificate']
        server.ssl_private_key = options['ssl_private_key']
        if options['ssl_certificate_chain']:
            server.ssl_certificate_chain = options['ssl_certificate_chain']
        server.ssl_cipher_list = options['ssl_cipher_list']
        server.ssl_no_renegotiation = options['ssl_no_renegotiation']

        ssl_password = conf.get_ssl_password()
        if ssl_password:
            server.ssl_password_cb = lambda *unused: ssl_password

    try:
        server.bind_server()
        drop_privileges_if_necessary(options)

        if isinstance(server.socket, SSLConnection):
            ciphers = server.socket.get_cipher_list()
            logging.info("List of enabled ciphers: {}".format(
                ':'.join(ciphers)))

        server.listen_and_loop()
    except KeyboardInterrupt:
        server.stop()