Ejemplo n.º 1
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        LOG.debug('Full set of CONF:')
        CONF.log_opt_values(LOG, std_logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = _signo_to_signame(self.sigcaught)
                LOG.info(_LI('Caught %s, stopping children'), signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                for pid in self.children:
                    os.kill(pid, signal.SIGHUP)
                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info(_LI("Wait called after thread killed.  Cleaning up."))

        self.stop()
Ejemplo n.º 2
0
    def wait(self):
        """Loop waiting on children to die and respawning as necessary."""

        systemd.notify_once()
        LOG.debug('Full set of CONF:')
        CONF.log_opt_values(LOG, logging.DEBUG)

        try:
            while True:
                self.handle_signal()
                self._respawn_children()
                # No signal means that stop was called.  Don't clean up here.
                if not self.sigcaught:
                    return

                signame = _signo_to_signame(self.sigcaught)
                LOG.info(_LI('Caught %s, stopping children'), signame)
                if not _is_sighup_and_daemon(self.sigcaught):
                    break

                cfg.CONF.reload_config_files()
                for service in set(
                    [wrap.service for wrap in self.children.values()]):
                    service.reset()

                for pid in self.children:
                    os.kill(pid, signal.SIGHUP)

                self.running = True
                self.sigcaught = None
        except eventlet.greenlet.GreenletExit:
            LOG.info(_LI("Wait called after thread killed. Cleaning up."))

        self.stop()
Ejemplo n.º 3
0
 def wait(self, ready_callback=None):
     systemd.notify_once()
     while True:
         self.handle_signal()
         status, signo = self._wait_for_exit_or_signal(ready_callback)
         if not _is_sighup_and_daemon(signo):
             return status
         self.restart()
Ejemplo n.º 4
0
 def wait(self, ready_callback=None):
     systemd.notify_once()
     while True:
         self.handle_signal()
         status, signo = self._wait_for_exit_or_signal(ready_callback)
         if not _is_sighup_and_daemon(signo):
             return status
         self.restart()
Ejemplo n.º 5
0
    def run_service(service, done):
        """Service start wrapper.

        :param service: service to run
        :param done: event to wait on until a shutdown is triggered
        :returns: None

        """
        service.start()
        systemd.notify_once()
        done.wait()
Ejemplo n.º 6
0
    def run_service(service, done):
        """Service start wrapper.

        :param service: service to run
        :param done: event to wait on until a shutdown is triggered
        :returns: None

        """
        service.start()
        systemd.notify_once()
        done.wait()
Ejemplo n.º 7
0
Archivo: wsgi.py Proyecto: nash-x/hws
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
Ejemplo n.º 8
0
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
Ejemplo n.º 9
0
def main():
    eventlet.monkey_patch()

    # the configuration will be read into the cfg.CONF global data structure
    config.parse(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _("ERROR: Unable to find configuration file via the default"
              " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
              " the '--config-file' option!"))
    try:
        neutron_service = service.serve_wsgi(service.NeutronApiService)
        systemd.notify_once()
        neutron_service.wait()
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
Ejemplo n.º 10
0
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.dispose()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
Ejemplo n.º 11
0
 def _launch(self, application, workers=0):
     service = WorkerService(self, application)
     if workers < 1:
         # The API service should run in the current process.
         self._server = service
         service.start()
         systemd.notify_once()
     else:
         # dispose the whole pool before os.fork, otherwise there will
         # be shared DB connections in child processes which may cause
         # DB errors.
         api.dispose()
         # The API service runs in a number of child processes.
         # Minimize the cost of checking for child exit by extending the
         # wait interval past the default of 0.01s.
         self._server = common_service.ProcessLauncher(wait_interval=1.0)
         self._server.launch_service(service, workers=workers)
Ejemplo n.º 12
0
    def start(self, application, port, host='0.0.0.0', workers=0):
        """Run a WSGI server with the given application."""
        self._host = host
        self._port = port
        backlog = CONF.backlog

        self._socket = self._get_socket(self._host,
                                        self._port,
                                        backlog=backlog)
        if workers < 1:
            # For the case where only one process is required.
            self._server = self.pool.spawn(self._run, application,
                                           self._socket)
            systemd.notify_once()
        else:
            # Minimize the cost of checking for child exit by extending the
            # wait interval past the default of 0.01s.
            self._launcher = common_service.ProcessLauncher(wait_interval=1.0)
            self._server = WorkerService(self, application)
            self._launcher.launch_service(self._server, workers=workers)
Ejemplo n.º 13
0
    def start(self, application, port, host='0.0.0.0', workers=0):
        """Run a WSGI server with the given application."""
        self._host = host
        self._port = port
        backlog = CONF.backlog

        self._socket = self._get_socket(self._host,
                                        self._port,
                                        backlog=backlog)
        if workers < 1:
            # For the case where only one process is required.
            self._server = self.pool.spawn(self._run, application,
                                           self._socket)
            systemd.notify_once()
        else:
            # Minimize the cost of checking for child exit by extending the
            # wait interval past the default of 0.01s.
            self._launcher = common_service.ProcessLauncher(wait_interval=1.0)
            self._server = WorkerService(self, application)
            self._launcher.launch_service(self._server, workers=workers)