Added optional arg to launch child processes

Removed unnecessary conditional stmts
Commented out reddwarf-api-workers in configs

Change-Id: I80505fbe2dfe84c2ad77d4f41cd0d876b90187ef
Implements: blueprint preforkreddwarf
This commit is contained in:
daniel-a-nguyen 2013-05-16 12:36:14 -07:00
parent 21dd6a1836
commit 16b42c9579
6 changed files with 13 additions and 5 deletions

View File

@ -34,7 +34,6 @@ if os.path.exists(os.path.join(possible_topdir, 'reddwarf', '__init__.py')):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
from reddwarf.common import cfg from reddwarf.common import cfg
from reddwarf.openstack.common import service
from reddwarf.openstack.common import log as logging from reddwarf.openstack.common import log as logging
from reddwarf.common import wsgi from reddwarf.common import wsgi
from reddwarf.db import get_db_api from reddwarf.db import get_db_api
@ -49,7 +48,8 @@ if __name__ == '__main__':
try: try:
get_db_api().configure_db(CONF) get_db_api().configure_db(CONF)
conf_file = CONF.find_file(CONF.api_paste_config) conf_file = CONF.find_file(CONF.api_paste_config)
launcher = wsgi.launch('reddwarf', CONF.bind_port or 8779, conf_file) launcher = wsgi.launch('reddwarf', CONF.bind_port or 8779, conf_file,
workers=CONF.reddwarf_api_workers)
launcher.wait() launcher.wait()
except RuntimeError as error: except RuntimeError as error:
import traceback import traceback

View File

@ -58,7 +58,8 @@ def run_server():
try: try:
get_db_api().configure_db(CONF) get_db_api().configure_db(CONF)
conf_file = CONF.find_file(CONF.api_paste_config) conf_file = CONF.find_file(CONF.api_paste_config)
launcher = wsgi.launch('reddwarf', CONF.bind_port or 8779, conf_file) launcher = wsgi.launch('reddwarf', CONF.bind_port or 8779, conf_file,
workers=CONF.reddwarf_api_workers)

View File

@ -11,6 +11,9 @@ bind_host = 0.0.0.0
# Port the bind the API server to # Port the bind the API server to
bind_port = 8779 bind_port = 8779
# Number of child processes to run
#reddwarf_api_workers=5
# AMQP Connection info # AMQP Connection info
rabbit_password=f7999d1955c5014aa32c rabbit_password=f7999d1955c5014aa32c

View File

@ -17,6 +17,9 @@ bind_host = 0.0.0.0
# Port the bind the API server to # Port the bind the API server to
bind_port = 8779 bind_port = 8779
# Number of child processes to run
#reddwarf_api_workers=5
# AMQP Connection info # AMQP Connection info
rabbit_password=f7999d1955c5014aa32c rabbit_password=f7999d1955c5014aa32c

View File

@ -113,6 +113,7 @@ common_opts = [
cfg.BoolOpt('reddwarf_security_groups_support', default=True), cfg.BoolOpt('reddwarf_security_groups_support', default=True),
cfg.StrOpt('reddwarf_security_group_rule_protocol', default='tcp'), cfg.StrOpt('reddwarf_security_group_rule_protocol', default='tcp'),
cfg.IntOpt('reddwarf_security_group_rule_port', default=3306), cfg.IntOpt('reddwarf_security_group_rule_port', default=3306),
cfg.IntOpt('reddwarf_api_workers', default=None),
cfg.IntOpt('usage_sleep_time', default=1, cfg.IntOpt('usage_sleep_time', default=1,
help="Time to sleep during the check active guest"), help="Time to sleep during the check active guest"),
cfg.IntOpt('usage_timeout', default=300, cfg.IntOpt('usage_timeout', default=300,

View File

@ -120,7 +120,7 @@ def versioned_urlmap(*args, **kwargs):
def launch(app_name, port, paste_config_file, data={}, def launch(app_name, port, paste_config_file, data={},
host='0.0.0.0', backlog=128, threads=1000): host='0.0.0.0', backlog=128, threads=1000, workers=None):
"""Launches a wsgi server based on the passed in paste_config_file. """Launches a wsgi server based on the passed in paste_config_file.
Launch provides a easy way to create a paste app from the config Launch provides a easy way to create a paste app from the config
@ -138,7 +138,7 @@ def launch(app_name, port, paste_config_file, data={},
app = pastedeploy.paste_deploy_app(paste_config_file, app_name, data) app = pastedeploy.paste_deploy_app(paste_config_file, app_name, data)
server = openstack_wsgi.Service(app, port, host=host, server = openstack_wsgi.Service(app, port, host=host,
backlog=backlog, threads=threads) backlog=backlog, threads=threads)
return service.launch(server) return service.launch(server, workers)
# Note: taken from Nova # Note: taken from Nova