bash Supervisord - 启动 backgroup python 脚本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18869925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 06:36:45  来源:igfitidea点击:

Supervisord - Start a backgroup python script

pythonbashsupervisord

提问by Hardy

I create bash to run python script start_queue.sh

我创建 bash 来运行 python 脚本 start_queue.sh

content of start_queue.sh

start_queue.sh 的内容

python /tmp/my_python_script.py & 

It's work when I run it in terminal. But I want to manage it using supervisord since I have few django website already manage by supervisord.

当我在终端中运行它时它的工作。但是我想使用 supervisord 来管理它,因为我很少有 django 网站已经由 supervisord 管理。

But I just get the error when start

但我只是在启动时收到错误

supervisor: couldn't exec /tmp/start_queue.sh: ENOEXEC
supervisor: child process was not spawned

This is how i config in supervisord

这就是我在 supervisord 中配置的方式

[group:scriptgroup]
programs=script_1

[program:script_1]
command=/tmp/start_queue.sh
directory=/tmp/
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/x.log
stdout_logfile_maxbytes=50MB
stdout_logfile_backups=50
stdout_capture_maxbytes=1MB
stdout_events_enabled=false
loglevel=info

It's possible to manage a backgroup process by supervisord, What did i wrong here. Please help.

可以通过 supervisord 管理后台进程,我在这里做错了什么。请帮忙。

回答by Shekhar

Add #!/bin/sh at the beginning of script.

在脚本的开头添加 #!/bin/sh。

回答by PersianGulf

You need to execute your shell scriptspawned. Spawnmeans when you kill it, it doesn't kill unless a set of cicumstances to be.

您需要执行您的shell scriptspawned. Spawn意味着当你杀死它时,它不会杀死,除非有一系列情况。

notes: supervisoris a python module that control proocessing. For your answer , please visit : http://stackful-dev.com/simplify-unix-process-herding-with-supervisor.html

注意:supervisor是一个控制处理的python 模块。对于您的答案,请访问:http: //stackful-dev.com/simplify-unix-process-herding-with-supervisor.html