From 23af620000b9b6cf3f26d10e8ed18101f6b2e2a6 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Wed, 27 Jan 2010 15:42:52 +0100 Subject: [PATCH] I thought global_conf would be enough to get all info from paster. Obviously I was wrong, we also need to use local_conf. Spotted by @gawel on irc. --- bin/gunicorn_paste | 9 ++++++++- examples/pylonstest/test.ini | 1 + gunicorn/main.py | 13 ++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/bin/gunicorn_paste b/bin/gunicorn_paste index 1a485fa5..524f3850 100644 --- a/bin/gunicorn_paste +++ b/bin/gunicorn_paste @@ -57,11 +57,18 @@ def get_app(parser, opts, args): pkg_resources.working_set.add_entry(relative_to) ctx = loadwsgi.loadcontext(loadwsgi.SERVER, config_url, relative_to=relative_to) + + if opts.workers: + workers = opts.workers + else: + workers = int(ctx.local_conf.get('workers', 1)) + debug = ctx.global_conf.get('debug') == "true" if debug: # we force to one worker in debug mode. - opts.workers = 1 + workers = 1 + opts.workers=workers app = loadapp(config_url, relative_to=relative_to) return app diff --git a/examples/pylonstest/test.ini b/examples/pylonstest/test.ini index 1f85da0e..9e9f770e 100644 --- a/examples/pylonstest/test.ini +++ b/examples/pylonstest/test.ini @@ -14,6 +14,7 @@ error_email_from = paste@localhost use = egg:gunicorn#main host = 127.0.0.1 port = 5000 +workers = 2 [app:main] use = egg:pylonstest diff --git a/gunicorn/main.py b/gunicorn/main.py index 7766dcab..52ced03f 100644 --- a/gunicorn/main.py +++ b/gunicorn/main.py @@ -23,7 +23,7 @@ def options(): help='Host to listen on. [%default]'), op.make_option('--port', dest='port', default=8000, type='int', help='Port to listen on. [%default]'), - op.make_option('--workers', dest='workers', default=1, type='int', + op.make_option('--workers', dest='workers', type='int', help='Number of workers to spawn. [%default]'), op.make_option('--log-level', dest='loglevel', default='info', help='Log level below which to silence messages. [%default]'), @@ -54,7 +54,7 @@ def main(usage, get_app): configure_logging(opts) app = get_app(parser, opts, args) - workers = opts.workers + workers = opts.workers or 1 if opts.debug: workers = 1 @@ -71,11 +71,10 @@ def paste_server(app, global_conf=None, host="127.0.0.1", port=None, port = 8000 bind_addr = (host, int(port)) - if not global_conf: - workers=1 - else: - workers = int(global_conf.get('workers', 1)) - + workers = kwargs.get("workers", 1) + if global_conf: + workers = int(global_conf.get('workers', workers)) + debug = global_conf.get('debug') == "true" if debug: # we force to one worker in debug mode.