Python oslo_service.service.ProcessLauncher() Examples
The following are 13
code examples of oslo_service.service.ProcessLauncher().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_service.service
, or try the search function
.
Example #1
Source File: test_service.py From oslo.service with Apache License 2.0 | 6 votes |
def test_parent_process_reload_config(self, is_sighup_and_daemon_mock, reload_config_files_mock, notify_once_mock, log_opt_values_mock, handle_signal_mock, respawn_children_mock, stop_mock, kill_mock, alarm_mock): is_sighup_and_daemon_mock.return_value = True respawn_children_mock.side_effect = [None, eventlet.greenlet.GreenletExit()] launcher = service.ProcessLauncher(self.conf) launcher.sigcaught = 1 launcher.children = {} wrap_mock = mock.Mock() launcher.children[222] = wrap_mock launcher.wait() reload_config_files_mock.assert_called_once_with() wrap_mock.service.reset.assert_called_once_with()
Example #2
Source File: wsgi.py From tacker with Apache License 2.0 | 6 votes |
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( CONF, wait_interval=1.0, restart_method='mutate') self._server = WorkerService(self, application) self._launcher.launch_service(self._server, workers=workers)
Example #3
Source File: service.py From zun with Apache License 2.0 | 5 votes |
def process_launcher(): return service.ProcessLauncher(CONF, restart_method='mutate')
Example #4
Source File: listener.py From searchlight with Apache License 2.0 | 5 votes |
def main(): service.prepare_service() launcher = os_service.ProcessLauncher(CONF, restart_method='mutate') launcher.launch_service( listener.ListenerService(), workers=CONF.listener.workers) launcher.wait()
Example #5
Source File: service.py From manila with Apache License 2.0 | 5 votes |
def process_launcher(): return service.ProcessLauncher(CONF, restart_method='mutate') # NOTE(vish): the global launcher is to maintain the existing # functionality of calling service.serve + # service.wait
Example #6
Source File: service.py From masakari with Apache License 2.0 | 5 votes |
def process_launcher(): return service.ProcessLauncher(CONF, restart_method='mutate') # NOTE: the global launcher is to maintain the existing # functionality of calling service.serve + # service.wait
Example #7
Source File: test_service.py From oslo.service with Apache License 2.0 | 5 votes |
def test_mutate_hook_process_launcher(self): """Test mutate_config_files is called by ProcessLauncher on SIGHUP. Forks happen in _spawn_service and ProcessLauncher. So we get three tiers of processes, the top tier being the test process. self.pid refers to the middle tier, which represents our application. Both service_maker and launcher_maker execute in the middle tier. The bottom tier is the workers. The behavior we want is that when the application (middle tier) receives a SIGHUP, it catches that, calls mutate_config_files and relaunches all the workers. This causes them to inherit the mutated config. """ mutate = multiprocessing.Event() ready = multiprocessing.Event() def service_maker(): self.conf.register_mutate_hook(lambda c, f: mutate.set()) return ServiceWithTimer(ready) def launcher_maker(): return service.ProcessLauncher(self.conf, restart_method='mutate') self.pid = self._spawn_service(1, service_maker, launcher_maker) timeout = 5 ready.wait(timeout) self.assertTrue(ready.is_set(), 'Service never became ready') ready.clear() self.assertFalse(mutate.is_set(), "Hook was called too early") os.kill(self.pid, signal.SIGHUP) ready.wait(timeout) self.assertTrue(ready.is_set(), 'Service never back after SIGHUP') self.assertTrue(mutate.is_set(), "Hook wasn't called")
Example #8
Source File: test_service.py From oslo.service with Apache License 2.0 | 5 votes |
def test_stop(self, signal_mock, alarm_mock): signal_mock.SIGTERM = 15 launcher = service.ProcessLauncher(self.conf) self.assertTrue(launcher.running) pid_nums = [22, 222] fakeServiceWrapper = service.ServiceWrapper(service.Service(), 1) launcher.children = {pid_nums[0]: fakeServiceWrapper, pid_nums[1]: fakeServiceWrapper} with mock.patch('oslo_service.service.os.kill') as mock_kill: with mock.patch.object(launcher, '_wait_child') as _wait_child: def fake_wait_child(): pid = pid_nums.pop() return launcher.children.pop(pid) _wait_child.side_effect = fake_wait_child with mock.patch('oslo_service.service.Service.stop') as \ mock_service_stop: mock_service_stop.side_effect = lambda: None launcher.stop() self.assertFalse(launcher.running) self.assertFalse(launcher.children) mock_kill.assert_has_calls([mock.call(222, signal_mock.SIGTERM), mock.call(22, signal_mock.SIGTERM)], any_order=True) self.assertEqual(2, mock_kill.call_count) mock_service_stop.assert_called_once_with()
Example #9
Source File: test_service.py From oslo.service with Apache License 2.0 | 5 votes |
def test_check_service_base(self, pipe_mock, green_pipe_mock, handle_signal_mock, start_child_mock): pipe_mock.return_value = [None, None] launcher = service.ProcessLauncher(self.conf) serv = _Service() launcher.launch_service(serv, workers=0)
Example #10
Source File: test_service.py From oslo.service with Apache License 2.0 | 5 votes |
def test_check_service_base_fails(self, pipe_mock, green_pipe_mock, handle_signal_mock, start_child_mock): pipe_mock.return_value = [None, None] launcher = service.ProcessLauncher(self.conf) class FooService(object): def __init__(self): pass serv = FooService() self.assertRaises(TypeError, launcher.launch_service, serv, 0)
Example #11
Source File: service.py From cyborg with Apache License 2.0 | 5 votes |
def process_launcher(): return service.ProcessLauncher(CONF, restart_method='mutate')
Example #12
Source File: service.py From karbor with Apache License 2.0 | 5 votes |
def process_launcher(): return service.ProcessLauncher(CONF) # NOTE(vish): the global launcher is to maintain the existing # functionality of calling service.serve + # service.wait
Example #13
Source File: service.py From karbor with Apache License 2.0 | 5 votes |
def get_launcher(): # Note(lpetrut): ProcessLauncher uses green pipes which fail on Windows # due to missing support of non-blocking I/O pipes. For this reason, the # service must be spawned differently on Windows, using the ServiceLauncher # class instead. if os.name == 'nt': return Launcher() else: return process_launcher()