【问题标题】:How to integrate a --worker-class of gunicorn in supervisor config setting?如何在主管配置设置中集成 --worker-class gunicorn?
【发布时间】:2015-06-01 03:02:17
【问题描述】:

我在服务器上配置了这样的主管:

[program:myproject]
command = /home/mydir/myproj/venv/bin/python /home/mydir/myproj/venv/bin/gunicorn manage:app -b <ip_address>:8000
directory = /home/mydir

我已经在我的虚拟环境中安装了 gevent,但我不知道如何在主管 command 变量上实现它,我可以像这样通过终端手动运行它:

gunicorn manage:app -b <ip_address>:8000 --worker-class gevent

当我像 python 和 gunicorn 一样在主管命令中调用 gevent 时,我尝试包含一个路径,但它不起作用,老实说,我不知道执行 gevent 的正确目录/文件是什么,我也不确定是否这是在主管中执行工人类的正确方法。我在 Ubuntu v14.04 上运行

有人吗?谢谢

【问题讨论】:

  • 读取supervisord运行此程序时生成的正常日志和错误日志。如果您仍然无法获得线索,请在此处粘贴日志。
  • 除了 gunicorn 之外,您不需要包含任何东西的完整路径。您根本不需要对 Python 的引用。 gunicorn 应该使用安装它的解释器。

标签: python flask ubuntu-14.04 gunicorn supervisord


【解决方案1】:

已经为此制定了解决方案。但我不是100%确定它是否正确,经过一百次搜索,我终于想出了一个可行的解决方案:)

here 得到这个,我在我的项目目录中创建了一个 gunicorn.conf.py 文件,其中包含:

worker_class = 'gevent'

并将此文件集成到主管配置设置中:

[program:myproject]
command = /home/mydir/myproj/venv/bin/python /home/mydir/myproj/venv/bin/gunicorn -c /home/mydir/myproj/gunicorn.conf.py manage:app -b <ip_address>:8000
directory = /home/mydir

并开始运行主管:

sudo supervisorctl start <my_project>

然后噗!它已经开始工作了!

【讨论】:

    猜你喜欢
    • 2018-03-27
    • 1970-01-01
    • 1970-01-01
    • 2020-05-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    相关资源
    最近更新 更多