neutron-server api worker process should be named to their role
The function of class "ProcessLauncher" is to fork multiple processes. the function of "WorkerService.start" is provider api service and set process title according to the parameter desc. when multiple API processes need to be launched, use "ProcessLauncher" (in module oslo_service.service) manage. call "ProcessLauncher.launch_service" with the num of processes and service instance to real launch. when the "ProcessLauncher" launch the service, it calls the "start" method of the service directly without passing any parameters. Starting API processes, the service object passed in is WorkerService (in module neutron.wsgi) object. In the current design, pass the "desc" in call "WorkerService.start", therefore, the desc cannot be set. This patch add the "desc" parameter to the initialization, when call "start" method, if set "desc", it will be used first. if not, "desc" passed in initialization are used. this design solves the problem and keeps compatibility. Closes-bug: #1910623 Change-Id: Ia37182e572ac4e9ae83cd03d7008aa42c7ea36c8
This commit is contained in:
parent
09f9cf9e95
commit
75e030dfbd
@ -60,7 +60,7 @@ def encode_body(body):
|
||||
class WorkerService(neutron_worker.NeutronBaseWorker):
|
||||
"""Wraps a worker to be handled by ProcessLauncher"""
|
||||
def __init__(self, service, application, set_proctitle, disable_ssl=False,
|
||||
worker_process_count=0):
|
||||
worker_process_count=0, desc=None):
|
||||
super(WorkerService, self).__init__(worker_process_count,
|
||||
set_proctitle)
|
||||
|
||||
@ -68,8 +68,10 @@ class WorkerService(neutron_worker.NeutronBaseWorker):
|
||||
self._application = application
|
||||
self._disable_ssl = disable_ssl
|
||||
self._server = None
|
||||
self.desc = desc
|
||||
|
||||
def start(self, desc=None):
|
||||
desc = desc or self.desc
|
||||
super(WorkerService, self).start(desc=desc)
|
||||
# When api worker is stopped it kills the eventlet wsgi server which
|
||||
# internally closes the wsgi server socket object. This server socket
|
||||
@ -172,12 +174,12 @@ class Server(object):
|
||||
self._port,
|
||||
backlog=backlog)
|
||||
|
||||
self._launch(application, workers)
|
||||
self._launch(application, workers, desc)
|
||||
|
||||
def _launch(self, application, workers=0, desc=None):
|
||||
set_proctitle = "off" if desc is None else CONF.setproctitle
|
||||
service = WorkerService(self, application, set_proctitle,
|
||||
self.disable_ssl, workers)
|
||||
self.disable_ssl, workers, desc)
|
||||
if workers < 1:
|
||||
# The API service should run in the current process.
|
||||
self._server = service
|
||||
|
Loading…
Reference in New Issue
Block a user