【问题标题】:Trying to get supervisor to create a worker for python-rq试图让主管为 python-rq 创建一个工作人员
【发布时间】:2020-03-05 20:12:02
【问题描述】:

我正试图让supervisor 使用python-RQ 在此pattern 之后生成一个工人,就像this stackoverflow 问题中提到的那样。我可以从终端手动启动工人,如下所示:

$ venv/bin/rq worker
14:35:27 Worker rq:worker:fd403822518a4f21802fa0dc417e526a: started, version 1.2.2
14:35:27 *** Listening on default...

效果很好。我可以确认工作人员存在于另一个终端中:

$ venv/bin/rq info
0 queues, 0 jobs total

fd403822518a4f21802fa0dc417e526a (b'' 41735): idle default
1 workers, 0 queues

现在开始使用 supervisor.... 这是我的 supervisord.conf 文件,位于同一目录中。

[supervisord]

;[program:worker]
command=venv/bin/rq worker
process_name=%(program_name)s-%(process_num)s
numprocs=1
directory=.
stopsignal=TERM
autostart=false
autorestart=false

我可以按如下方式启动主管:

$ venv/bin/supervisord -n
2020-03-05 14:36:45,079 INFO supervisord started with pid 41757

但是,在检查新工人时,我发现它不存在。

$ venv/bin/rq info
0 queues, 0 jobs total

0 workers, 0 queues

我已经尝试了许多其他方法来让这个工人开始,比如......

...在虚拟环境中:

$ source venv/bin/activate
(venv) $ rq worker
*** Listening on default...

...使用 shell 文件

#!/bin/bash
source /venv/bin/activate
rq worker low

$ ./start.sh
*** Listening on default...

...使用 python 脚本

$ venv/bin/python3 worker.py
*** Listening on default...

手动启动时,它们都可以正常工作。在supervisord.conf 中更改command= 似乎没有什么不同。找不到工人。我错过了什么?为什么主管不启动工人?我在 Mac OS 中运行它,我的文件结构如下:

.
|--__pycache__
|--supervisord.conf
|--supervisord.log
|--supervisord.pid
|--main.py
|--task.py
|--venv
   |--bin
      |--rq
      |--supervisord
      |--...etc
   |--include
   |--lib
   |--pyenv.cfg

提前致谢。

【问题讨论】:

    标签: python supervisord python-rq


    【解决方案1】:

    supervisord.conf 有两个问题,阻止了 worker 启动。修改后的配置文件如下:

    [supervisord]
    
    [program:worker]
    command=venv/bin/rqworker
    process_name=%(program_name)s-%(process_num)s
    numprocs=1
    directory=.
    stopsignal=TERM
    autostart=true
    autorestart=false
    

    首先,[program:worker] 行实际上已被注释掉。我一定是从注释掉的示例文件中取出了这一行而没有意识到。但是删除评论仍然没有启动工人......我还必须设置autostart=true,因为启动主管不会自动启动命令。

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 2020-12-05
      • 1970-01-01
      • 2020-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-06-30
      • 2018-11-05
      相关资源
      最近更新 更多