python - 在Supervisord中通过sh脚本启动程序

标签 python sh supervisord

我有一个脚本 run.sh,它启动一个 python pub-sub 监听器,如下所示:

export MY_ENV_VAR='/root/config/'
python /usr/local/lib/python2.7/dist-packages/listener/main.py

我设置了 Supervisord,以便它允许我运行我的脚本,如下所示:

[program:Listener]
command=/bin/bash run.sh
directory=/root/listener
process_name=%(program_name)s
autostart=true
autorestart=true
startretries=3

我的问题是:当我转到端口 9001 处的 Supervisord UI 并按监听器行旁边的 STOP 时,我真的会停止我的监听器吗?我的印象是,由于supervisord指向.sh脚本,当我点击STOP时,它不会停止python脚本。

最佳答案

您可以尝试指定

stopasgroup=true

配置文件中的参数。

所以supervisord也会向子进程发送kill信号:

http://supervisord.org/configuration.html

关于python - 在Supervisord中通过sh脚本启动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34496949/

相关文章:

linux - 在 linux 中使用 shell 脚本从单词中读取特定字符

docker - 如何在docker中将参数传递给supervisord?

linux - 如何让 Supervisord 无条件运行?

python - Gunicorn 在被 supervisord 调用时抛出 OSError 打开文件

python - 数组比较

python - 使用基类的属性/属性作为表列?

python - 从 python 作为 google 组发送电子邮件

linux - 如何将以下日期更改为 2 个特定表格? (Linux 终端/shell )

linux - 使用标准输入将一些十六进制字符串放入 xxd 不会生成任何输出

python - 如何在 .csv 文件中转义字符串 Python 2.7 中的逗号