Exemple #1
0
def PrepNoded(options, _):
    """Preparation node daemon function, executed with the PID file held.

  """
    if options.mlock:
        request_executor_class = MlockallRequestExecutor
        try:
            utils.Mlockall()
        except errors.NoCtypesError:
            logging.warning("Cannot set memory lock, ctypes module not found")
            request_executor_class = http.server.HttpServerRequestExecutor
    else:
        request_executor_class = http.server.HttpServerRequestExecutor

    # Read SSL certificate
    if options.ssl:
        ssl_params = http.HttpSslParams(ssl_key_path=options.ssl_key,
                                        ssl_cert_path=options.ssl_cert)
    else:
        ssl_params = None

    err = _PrepareQueueLock()
    if err is not None:
        # this might be some kind of file-system/permission error; while
        # this breaks the job queue functionality, we shouldn't prevent
        # startup of the whole node daemon because of this
        logging.critical("Can't init/verify the queue, proceeding anyway: %s",
                         err)

    handler = NodeRequestHandler()

    mainloop = daemon.Mainloop()
    server = http.server.HttpServer(
        mainloop,
        options.bind_address,
        options.port,
        options.max_clients,
        handler,
        ssl_params=ssl_params,
        ssl_verify_peer=True,
        request_executor_class=request_executor_class,
        ssl_verify_callback=SSLVerifyPeer)
    server.Start()

    return (mainloop, server)
    def __init__(self, *args, **kwargs):
        utils.Mlockall()

        http.server.HttpServerRequestExecutor.__init__(self, *args, **kwargs)
Exemple #3
0
 def test(self):
     if utils.ctypes:
         utils.Mlockall()