Unify workers options for API services
This patch change behaviour of launching API services for different numbers of workers: - workers < 0 -> is not allowed - workers == 0 -> as much worker *processes* as CPU cores - workers == 1 -> no child *processes*, single *green thread* - workers > 1 -> specified number of worker *processes* Note: According with old behaviour following services have corresponding defaul values: - heat-api -> '0', instead of function for calculation number of cores. - heat-api-cfn -> '1', instead of '0' (i.e. one *green thread*) - heat-api-cw -> '1', instead of '0' (i.e. one *green thread*) Also updated number of workers for functional tests. It's necessary, because priveous value was '1', which now mean one single thread. (Previously it was one worker). Change-Id: Idebd19c62adea02d9181236f6cbfed090acb32b9 Closes-Bug: #1523390
This commit is contained in:
parent
336f0f8f34
commit
bf20657824
@ -76,8 +76,10 @@ api_opts = [
|
|||||||
help=_("Location of the SSL key file to use "
|
help=_("Location of the SSL key file to use "
|
||||||
"for enabling SSL mode."),
|
"for enabling SSL mode."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('workers', default=processutils.get_worker_count(),
|
cfg.IntOpt('workers', default=0,
|
||||||
help=_("Number of workers for Heat service."),
|
help=_("Number of workers for Heat service. "
|
||||||
|
"Default value 0 means, that service will start number "
|
||||||
|
"of workers equal number of cores on server."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('max_header_line', default=16384,
|
cfg.IntOpt('max_header_line', default=16384,
|
||||||
help=_('Maximum line size of message headers to be accepted. '
|
help=_('Maximum line size of message headers to be accepted. '
|
||||||
@ -114,7 +116,7 @@ api_cfn_opts = [
|
|||||||
help=_("Location of the SSL key file to use "
|
help=_("Location of the SSL key file to use "
|
||||||
"for enabling SSL mode."),
|
"for enabling SSL mode."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('workers', default=0,
|
cfg.IntOpt('workers', default=1,
|
||||||
help=_("Number of workers for Heat service."),
|
help=_("Number of workers for Heat service."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('max_header_line', default=16384,
|
cfg.IntOpt('max_header_line', default=16384,
|
||||||
@ -152,7 +154,7 @@ api_cw_opts = [
|
|||||||
help=_("Location of the SSL key file to use "
|
help=_("Location of the SSL key file to use "
|
||||||
"for enabling SSL mode."),
|
"for enabling SSL mode."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('workers', default=0,
|
cfg.IntOpt('workers', default=1,
|
||||||
help=_("Number of workers for Heat service."),
|
help=_("Number of workers for Heat service."),
|
||||||
deprecated_group='DEFAULT'),
|
deprecated_group='DEFAULT'),
|
||||||
cfg.IntOpt('max_header_line', default=16384,
|
cfg.IntOpt('max_header_line', default=16384,
|
||||||
@ -310,17 +312,28 @@ class Server(object):
|
|||||||
self.start_wsgi()
|
self.start_wsgi()
|
||||||
|
|
||||||
def start_wsgi(self):
|
def start_wsgi(self):
|
||||||
if self.conf.workers == 0:
|
workers = self.conf.workers
|
||||||
|
# raise error if workers is incorrect value
|
||||||
|
if workers < 0:
|
||||||
|
raise ValueError("Number of workers should be more or equal '0'!")
|
||||||
|
# childs == num of cores
|
||||||
|
if workers == 0:
|
||||||
|
childs_num = processutils.get_worker_count()
|
||||||
|
# launch only one GreenPool without childs
|
||||||
|
elif workers == 1:
|
||||||
# Useful for profiling, test, debug etc.
|
# Useful for profiling, test, debug etc.
|
||||||
self.pool = eventlet.GreenPool(size=self.threads)
|
self.pool = eventlet.GreenPool(size=self.threads)
|
||||||
self.pool.spawn_n(self._single_run, self.application, self.sock)
|
self.pool.spawn_n(self._single_run, self.application, self.sock)
|
||||||
return
|
return
|
||||||
|
# childs equal specified value of workers
|
||||||
|
else:
|
||||||
|
childs_num = workers
|
||||||
|
|
||||||
LOG.info(_LI("Starting %d workers"), self.conf.workers)
|
LOG.info(_LI("Starting %d workers"), workers)
|
||||||
signal.signal(signal.SIGTERM, self.kill_children)
|
signal.signal(signal.SIGTERM, self.kill_children)
|
||||||
signal.signal(signal.SIGINT, self.kill_children)
|
signal.signal(signal.SIGINT, self.kill_children)
|
||||||
signal.signal(signal.SIGHUP, self.hup)
|
signal.signal(signal.SIGHUP, self.hup)
|
||||||
while len(self.children) < self.conf.workers:
|
while len(self.children) < childs_num:
|
||||||
self.run_child()
|
self.run_child()
|
||||||
|
|
||||||
def wait_on_children(self):
|
def wait_on_children(self):
|
||||||
|
@ -30,9 +30,9 @@ echo -e 'notification_driver=messagingv2\n' >> $localconf
|
|||||||
echo -e 'hidden_stack_tags=hidden\n' >> $localconf
|
echo -e 'hidden_stack_tags=hidden\n' >> $localconf
|
||||||
echo -e 'encrypt_parameters_and_properties=True\n' >> $localconf
|
echo -e 'encrypt_parameters_and_properties=True\n' >> $localconf
|
||||||
|
|
||||||
echo -e '[heat_api]\nworkers=1\n' >> $localconf
|
echo -e '[heat_api]\nworkers=2\n' >> $localconf
|
||||||
echo -e '[heat_api_cfn]\nworkers=1\n' >> $localconf
|
echo -e '[heat_api_cfn]\nworkers=2\n' >> $localconf
|
||||||
echo -e '[heat_api_cloudwatch]\nworkers=1\n' >> $localconf
|
echo -e '[heat_api_cloudwatch]\nworkers=2\n' >> $localconf
|
||||||
|
|
||||||
echo -e '[cache]\nenabled=True\n' >> $localconf
|
echo -e '[cache]\nenabled=True\n' >> $localconf
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user