From 761ce945ac99bf235d1dffcd20ec67ee8a9ca6f7 Mon Sep 17 00:00:00 2001 From: Guido Trotter <ultrotter@google.com> Date: Wed, 16 Jul 2008 09:48:20 +0000 Subject: [PATCH] Fork ganeti-noded Create a new ForkingHTTPServer in ganeti-noded by deriving both from NodeDaemonHttpServer and ForkingMixin. This will allow us to process concurrent requests. Reviewed-by: imsnah --- daemons/ganeti-noded | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 0cbe68844..c740105d3 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -27,6 +27,7 @@ import os import sys import traceback +import SocketServer import errno import logging @@ -537,6 +538,15 @@ class NodeDaemonHttpServer(http.HTTPServer): http.HTTPServer.__init__(self, server_address, NodeDaemonRequestHandler) +class ForkingHTTPServer(SocketServer.ForkingMixIn, NodeDaemonHttpServer): + """Forking HTTP Server. + + This inherits from ForkingMixIn and HTTPServer in order to fork for each + request we handle. This allows more requests to be handled concurrently. + + """ + + def ParseOptions(): """Parse the command line options. @@ -603,7 +613,12 @@ def main(): global _EXIT_GANETI_NODED - httpd = NodeDaemonHttpServer(('', port)) + if options.fork: + httpd = ForkingHTTPServer(('', port)) + else: + httpd = NodeDaemonHttpServer(('', port)) + + # FIXME: updating _EXIT_GANETI_NODED doesn't work when forking while (not _EXIT_GANETI_NODED): httpd.handle_request() -- GitLab