diff --git a/bin/reddwarf-api b/bin/reddwarf-api index 029f54dfc3..b11f7feaf8 100755 --- a/bin/reddwarf-api +++ b/bin/reddwarf-api @@ -34,7 +34,6 @@ if os.path.exists(os.path.join(possible_topdir, 'reddwarf', '__init__.py')): sys.path.insert(0, possible_topdir) from reddwarf.common import cfg -from reddwarf.openstack.common import service from reddwarf.openstack.common import log as logging from reddwarf.common import wsgi from reddwarf.db import get_db_api @@ -49,7 +48,8 @@ if __name__ == '__main__': try: get_db_api().configure_db(CONF) 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() except RuntimeError as error: import traceback diff --git a/bin/reddwarf-server b/bin/reddwarf-server index c562034bba..7760eec5e8 100755 --- a/bin/reddwarf-server +++ b/bin/reddwarf-server @@ -58,7 +58,8 @@ def run_server(): try: get_db_api().configure_db(CONF) 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) diff --git a/etc/reddwarf/reddwarf.conf.sample b/etc/reddwarf/reddwarf.conf.sample index 43b1b7708a..38970817c4 100644 --- a/etc/reddwarf/reddwarf.conf.sample +++ b/etc/reddwarf/reddwarf.conf.sample @@ -11,6 +11,9 @@ bind_host = 0.0.0.0 # Port the bind the API server to bind_port = 8779 +# Number of child processes to run +#reddwarf_api_workers=5 + # AMQP Connection info rabbit_password=f7999d1955c5014aa32c diff --git a/etc/reddwarf/reddwarf.conf.test b/etc/reddwarf/reddwarf.conf.test index d105c48d61..46ec47ce11 100644 --- a/etc/reddwarf/reddwarf.conf.test +++ b/etc/reddwarf/reddwarf.conf.test @@ -17,6 +17,9 @@ bind_host = 0.0.0.0 # Port the bind the API server to bind_port = 8779 +# Number of child processes to run +#reddwarf_api_workers=5 + # AMQP Connection info rabbit_password=f7999d1955c5014aa32c diff --git a/reddwarf/common/cfg.py b/reddwarf/common/cfg.py index 60d590cd44..234d3215e4 100644 --- a/reddwarf/common/cfg.py +++ b/reddwarf/common/cfg.py @@ -113,6 +113,7 @@ common_opts = [ cfg.BoolOpt('reddwarf_security_groups_support', default=True), cfg.StrOpt('reddwarf_security_group_rule_protocol', default='tcp'), cfg.IntOpt('reddwarf_security_group_rule_port', default=3306), + cfg.IntOpt('reddwarf_api_workers', default=None), cfg.IntOpt('usage_sleep_time', default=1, help="Time to sleep during the check active guest"), cfg.IntOpt('usage_timeout', default=300, diff --git a/reddwarf/common/wsgi.py b/reddwarf/common/wsgi.py index 95de2f96b7..5ddded093e 100644 --- a/reddwarf/common/wsgi.py +++ b/reddwarf/common/wsgi.py @@ -120,7 +120,7 @@ def versioned_urlmap(*args, **kwargs): 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. 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) server = openstack_wsgi.Service(app, port, host=host, backlog=backlog, threads=threads) - return service.launch(server) + return service.launch(server, workers) # Note: taken from Nova