Merge "Re-use existing ProcessLauncher from wsgi in RPC workers" into stable/queens
This commit is contained in:
commit
4a6f39b97c
|
@ -27,7 +27,7 @@ def eventlet_wsgi_server():
|
||||||
|
|
||||||
def start_api_and_rpc_workers(neutron_api):
|
def start_api_and_rpc_workers(neutron_api):
|
||||||
try:
|
try:
|
||||||
worker_launcher = service.start_all_workers()
|
worker_launcher = service.start_all_workers(neutron_api)
|
||||||
|
|
||||||
pool = eventlet.GreenPool()
|
pool = eventlet.GreenPool()
|
||||||
api_thread = pool.spawn(neutron_api.wait)
|
api_thread = pool.spawn(neutron_api.wait)
|
||||||
|
|
|
@ -217,7 +217,7 @@ class AllServicesNeutronWorker(neutron_worker.BaseWorker):
|
||||||
self._launcher.restart()
|
self._launcher.restart()
|
||||||
|
|
||||||
|
|
||||||
def _start_workers(workers):
|
def _start_workers(workers, neutron_api=None):
|
||||||
process_workers = [
|
process_workers = [
|
||||||
plugin_worker for plugin_worker in workers
|
plugin_worker for plugin_worker in workers
|
||||||
if plugin_worker.worker_process_count > 0
|
if plugin_worker.worker_process_count > 0
|
||||||
|
@ -225,9 +225,14 @@ def _start_workers(workers):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if process_workers:
|
if process_workers:
|
||||||
worker_launcher = common_service.ProcessLauncher(
|
# Get eventual already existing instance from WSGI app
|
||||||
cfg.CONF, wait_interval=1.0
|
worker_launcher = None
|
||||||
)
|
if neutron_api:
|
||||||
|
worker_launcher = neutron_api.wsgi_app.process_launcher
|
||||||
|
if worker_launcher is None:
|
||||||
|
worker_launcher = common_service.ProcessLauncher(
|
||||||
|
cfg.CONF, wait_interval=1.0
|
||||||
|
)
|
||||||
|
|
||||||
# add extra process worker and spawn there all workers with
|
# add extra process worker and spawn there all workers with
|
||||||
# worker_process_count == 0
|
# worker_process_count == 0
|
||||||
|
@ -259,9 +264,9 @@ def _start_workers(workers):
|
||||||
'details.')
|
'details.')
|
||||||
|
|
||||||
|
|
||||||
def start_all_workers():
|
def start_all_workers(neutron_api=None):
|
||||||
workers = _get_rpc_workers() + _get_plugins_workers()
|
workers = _get_rpc_workers() + _get_plugins_workers()
|
||||||
launcher = _start_workers(workers)
|
launcher = _start_workers(workers, neutron_api)
|
||||||
registry.publish(resources.PROCESS, events.AFTER_SPAWN, None)
|
registry.publish(resources.PROCESS, events.AFTER_SPAWN, None)
|
||||||
return launcher
|
return launcher
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,12 @@ class Server(object):
|
||||||
log_format=CONF.wsgi_log_format,
|
log_format=CONF.wsgi_log_format,
|
||||||
socket_timeout=self.client_socket_timeout)
|
socket_timeout=self.client_socket_timeout)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def process_launcher(self):
|
||||||
|
if isinstance(self._server, common_service.ProcessLauncher):
|
||||||
|
return self._server
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
class Request(wsgi.Request):
|
class Request(wsgi.Request):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue