diff --git a/docs/source/run.rst b/docs/source/run.rst index 8741ba85..efbce4fd 100644 --- a/docs/source/run.rst +++ b/docs/source/run.rst @@ -96,5 +96,9 @@ For example: gunicorn --paste development.ini -b :8080 --chdir /path/to/project +Or use a different application: + + gunicorn --paste development.ini#admin -b :8080 --chdir /path/to/project + It is all here. No configuration files nor additional python modules to write !! diff --git a/gunicorn/app/pasterapp.py b/gunicorn/app/pasterapp.py index d4aec32a..2c4d1ef4 100644 --- a/gunicorn/app/pasterapp.py +++ b/gunicorn/app/pasterapp.py @@ -25,6 +25,7 @@ def paste_config(gconfig, config_url, relative_to, global_conf=None): sys.path.insert(0, relative_to) pkg_resources.working_set.add_entry(relative_to) + config_url = config_url.split('#')[0] cx = loadwsgi.loadcontext(SERVER, config_url, relative_to=relative_to, global_conf=global_conf) gc, lc = cx.global_conf.copy(), cx.local_conf.copy() diff --git a/gunicorn/app/wsgiapp.py b/gunicorn/app/wsgiapp.py index e997d17b..82b4547e 100644 --- a/gunicorn/app/wsgiapp.py +++ b/gunicorn/app/wsgiapp.py @@ -14,14 +14,18 @@ from gunicorn import util class WSGIApplication(Application): def init(self, parser, opts, args): if opts.paste and opts.paste is not None: + app_name = 'main' + path = opts.paste + if '#' in path: + path, app_name = path.split('#') path = os.path.abspath(os.path.normpath( - os.path.join(util.getcwd(), opts.paste))) + os.path.join(util.getcwd(), path))) if not os.path.exists(path): raise ConfigError("%r not found" % path) # paste application, load the config - self.cfgurl = 'config:%s' % path + self.cfgurl = 'config:%s#%s' % (path, app_name) self.relpath = os.path.dirname(path) from .pasterapp import paste_config diff --git a/gunicorn/config.py b/gunicorn/config.py index 0776da95..a56450bb 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -1222,7 +1222,12 @@ class Paste(Setting): validator = validate_string default = None desc = """\ - Load a paste.deploy config file. + Load a paste.deploy config file. The argument may contain a "#" symbol + followed by the name of an app section from the config file, e.g. + "production.ini#admin". + + At this time, using alternate server blocks is not supported. Use the + command line arguments to control server configuration instead. """