[jamespage,r=gnuoy] Add support for worker process configuration

This commit is contained in:
James Page 2014-10-08 11:40:04 +01:00
commit c9ec9ef09f
6 changed files with 32 additions and 1 deletions

View File

@ -146,3 +146,10 @@ options:
order for this charm to function correctly, the privacy extension must be order for this charm to function correctly, the privacy extension must be
disabled and a non-temporary address must be configured/available on disabled and a non-temporary address must be configured/available on
your network interface. your network interface.
worker-multiplier:
type: int
default: 2
description: |
The CPU core multiplier to use when configuring worker processes for
Glance. By default, the number of workers for each daemon is set to
twice the number of CPU cores a service unit has.

View File

@ -903,3 +903,22 @@ class BindHostContext(OSContextGenerator):
return { return {
'bind_host': '0.0.0.0' 'bind_host': '0.0.0.0'
} }
class WorkerConfigContext(OSContextGenerator):
@property
def num_cpus(self):
try:
from psutil import NUM_CPUS
except ImportError:
apt_install('python-psutil', fatal=True)
from psutil import NUM_CPUS
return NUM_CPUS
def __call__(self):
multiplier = config('worker-multiplier') or 1
ctxt = {
"workers": self.num_cpus * multiplier
}
return ctxt

View File

@ -83,7 +83,8 @@ CONFIG_FILES = OrderedDict([
context.IdentityServiceContext(), context.IdentityServiceContext(),
context.SyslogContext(), context.SyslogContext(),
glance_contexts.LoggingConfigContext(), glance_contexts.LoggingConfigContext(),
glance_contexts.GlanceIPv6Context()], glance_contexts.GlanceIPv6Context(),
context.WorkerConfigContext()],
'services': ['glance-registry'] 'services': ['glance-registry']
}), }),
(GLANCE_API_CONF, { (GLANCE_API_CONF, {
@ -97,6 +98,7 @@ CONFIG_FILES = OrderedDict([
context.SyslogContext(), context.SyslogContext(),
glance_contexts.LoggingConfigContext(), glance_contexts.LoggingConfigContext(),
glance_contexts.GlanceIPv6Context(), glance_contexts.GlanceIPv6Context(),
context.WorkerConfigContext(),
glance_contexts.MultiStoreContext()], glance_contexts.MultiStoreContext()],
'services': ['glance-api'] 'services': ['glance-api']
}), }),

View File

@ -2,6 +2,7 @@
verbose = {{ verbose }} verbose = {{ verbose }}
use_syslog = {{ use_syslog }} use_syslog = {{ use_syslog }}
debug = {{ debug }} debug = {{ debug }}
workers = {{ workers }}
{% if rbd_pool -%} {% if rbd_pool -%}
default_store = rbd default_store = rbd

View File

@ -2,6 +2,7 @@
verbose = {{ verbose }} verbose = {{ verbose }}
use_syslog = {{ use_syslog }} use_syslog = {{ use_syslog }}
debug = {{ debug }} debug = {{ debug }}
workers = {{ workers }}
bind_host = {{ bind_host }} bind_host = {{ bind_host }}
bind_port = 9191 bind_port = 9191

View File

@ -2,6 +2,7 @@
verbose = {{ verbose }} verbose = {{ verbose }}
use_syslog = {{ use_syslog }} use_syslog = {{ use_syslog }}
debug = {{ debug }} debug = {{ debug }}
workers = {{ workers }}
known_stores = {{ known_stores }} known_stores = {{ known_stores }}
{% if rbd_pool -%} {% if rbd_pool -%}