gunicorn

简要说明

使用Gunicorn运行基于Pyramid的应用程序非常简单:

$ gunicorn --paste production.ini

完整说明

类似于 pserve 命令与 Pyramid 一起提供,gunicorn也可以直接使用项目的ini文件,例如 production.ini , to launch your application. 只要供应 --paste 命令行选项以及配置文件的路径 gunicorn 命令,它将尝试加载应用程序。

As documented in the section Paste Deployment , you may also add gunicorn specific settings to the [server:main] 部分,并继续使用 pserve 命令。

以下配置将导致gunicorn监听unix套接字,使用四个worker,预加载应用程序,将accesslog行输出到stderr并使用debug日志级别。

1[server:main]
2use = egg:gunicorn#main
3bind = unix:/var/run/app.sock
4workers = 4
5preload = true
6accesslog = -
7loglevel = debug

For all configuration options that may be used, have a look at the available settings .

请记住,在gunicorn配置文件中定义的设置优先于在INI文件中建立的设置。

为了所有这些工作,gunicorn使用的python解释器还需要能够加载应用程序。换句话说,Gunicorn和您的应用程序需要安装在同一个内部并在其中使用。 virtualenv .

当然, paste 选项还可以与其他可能适用于部署情况的Gunicorn选项组合。你也可能想把 nginx 在Gunicorn面前,让一些流程经理监督Gunicorn。请看一下 gunicorn website 以及 gunicorn documentation on deployment 有关这些主题的更多信息。