mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
gunicorn server factory for paster.
This commit is contained in:
parent
e699a50952
commit
63d45ef181
19
README.rst
19
README.rst
@ -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:**
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user