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
|
$ gunicorn --workers=2 test:app
|
||||||
|
|
||||||
|
|
||||||
|
Django projects
|
||||||
|
+++++++++++++++
|
||||||
|
|
||||||
For django projects use the `gunicorn_django` command::
|
For django projects use the `gunicorn_django` command::
|
||||||
|
|
||||||
$ cd yourdjangoproject
|
$ cd yourdjangoproject
|
||||||
$ gunicorn_django --workers=2
|
$ gunicorn_django --workers=2
|
||||||
|
|
||||||
|
Paste-compatible projects
|
||||||
|
+++++++++++++++++++++++++
|
||||||
|
|
||||||
For paste-compatible projects (like Pylons) use the `gunicorn_paste` command::
|
For paste-compatible projects (like Pylons) use the `gunicorn_paste` command::
|
||||||
|
|
||||||
$ cd your pasteproject
|
$ cd your pasteproject
|
||||||
$ gunicorn_paste --workers=2 development.ini
|
$ 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:**
|
**WARNING:**
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ smtp_server = localhost
|
|||||||
error_email_from = paste@localhost
|
error_email_from = paste@localhost
|
||||||
|
|
||||||
[server:main]
|
[server:main]
|
||||||
use = egg:Paste#http
|
use = egg:gunicorn#main
|
||||||
host = 127.0.0.1
|
host = 127.0.0.1
|
||||||
port = 5000
|
port = 5000
|
||||||
|
|
||||||
|
|||||||
@ -55,3 +55,24 @@ def main(usage, get_app):
|
|||||||
arbiter = Arbiter((opts.host, opts.port), opts.workers, app)
|
arbiter = Arbiter((opts.host, opts.port), opts.workers, app)
|
||||||
arbiter.run()
|
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()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
setup.py
5
setup.py
@ -40,7 +40,10 @@ setup(
|
|||||||
include_package_data = True,
|
include_package_data = True,
|
||||||
scripts = ['bin/gunicorn', 'bin/gunicorn_django', 'bin/gunicorn_paste'],
|
scripts = ['bin/gunicorn', 'bin/gunicorn_django', 'bin/gunicorn_paste'],
|
||||||
|
|
||||||
|
entry_points="""
|
||||||
|
[paste.server_runner]
|
||||||
|
main=gunicorn.main:paste_server
|
||||||
|
""",
|
||||||
test_suite = 'nose.collector',
|
test_suite = 'nose.collector',
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user