gunicorn server factory for paster.

This commit is contained in:
Benoit Chesneau 2010-01-23 16:46:49 +01:00
parent e699a50952
commit 63d45ef181
4 changed files with 45 additions and 2 deletions

View File

@ -37,16 +37,35 @@ Example with test app::
$ gunicorn --workers=2 test:app
Django projects
+++++++++++++++
For django projects use the `gunicorn_django` command::
$ cd yourdjangoproject
$ gunicorn_django --workers=2
Paste-compatible projects
+++++++++++++++++++++++++
For paste-compatible projects (like Pylons) use the `gunicorn_paste` command::
$ cd your pasteproject
$ gunicorn_paste --workers=2 development.ini
or usual paster command::
$ cd your pasteproject
$ paster server development workers=2
In last case don't forget to add a server section for gunicorn. Here is an example that use
gunicorn as main server::
[server:main]
use = egg:gunicorn#main
host = 127.0.0.1
port = 5000
**WARNING:**

View File

@ -11,7 +11,7 @@ smtp_server = localhost
error_email_from = paste@localhost
[server:main]
use = egg:Paste#http
use = egg:gunicorn#main
host = 127.0.0.1
port = 5000

View File

@ -54,4 +54,25 @@ def main(usage, get_app):
app = get_app(parser, opts, args)
arbiter = Arbiter((opts.host, opts.port), opts.workers, app)
arbiter.run()
def paste_server(app, global_conf=None, host="127.0.0.1", port=None, *args, **kw):
if not port:
if ':' in host:
host, port = host.split(':', 1)
else:
port = 8000
bind_addr = (host, int(port))
if not global_conf:
workers=1
else:
workers = int(global_conf.get('workers', 1))
arbiter = Arbiter(bind_addr, workers, app)
arbiter.run()

View File

@ -40,7 +40,10 @@ setup(
include_package_data = True,
scripts = ['bin/gunicorn', 'bin/gunicorn_django', 'bin/gunicorn_paste'],
entry_points="""
[paste.server_runner]
main=gunicorn.main:paste_server
""",
test_suite = 'nose.collector',
)