Revision cfe3c70f

b/daemons/ganeti-rapi
25 25
import optparse
26 26
import sys
27 27
import os
28
import signal
28 29

  
29 30
from ganeti import constants
30 31
from ganeti import errors
......
66 67
    return result
67 68

  
68 69

  
70
class RESTHttpServer(http.HTTPServer):
71
  def serve_forever(self):
72
    """Handle one request at a time until told to quit."""
73
    sighandler = utils.SignalHandler([signal.SIGINT, signal.SIGTERM])
74
    try:
75
      while not sighandler.called:
76
        self.handle_request()
77
    finally:
78
      sighandler.Reset()
79

  
80

  
69 81
def ParseOptions():
70 82
  """Parse the command line options.
71 83

  
......
123 135
  log_fd = open(constants.LOG_RAPIACCESS, 'a')
124 136
  try:
125 137
    apache_log = http.ApacheLogfile(log_fd)
126
    httpd = http.HTTPServer(("", options.port), RESTRequestHandler,
127
                            httplog=apache_log)
138
    httpd = RESTHttpServer(("", options.port), RESTRequestHandler,
139
                           httplog=apache_log)
128 140
    try:
129 141
      httpd.serve_forever()
130 142
    finally:

Also available in: Unified diff