Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
主管保持huey python运行_Python_Redis_Supervisord - Fatal编程技术网

主管保持huey python运行

主管保持huey python运行,python,redis,supervisord,Python,Redis,Supervisord,我试图让主管监视和维护一个使用Huey(redis类型的队列)的python脚本 我的主管程序配置如下所示: [program:smsbot_handler] directory=/home/ubuntu/virt_env/virt1/app/ command=/home/ubuntu/virt_env/virt1/bin/huey_consumer.py main.huey --threads=3 stdout_logfile=/home/ubuntu/smsbot_handler_log.t

我试图让主管监视和维护一个使用Huey(redis类型的队列)的python脚本

我的主管程序配置如下所示:

[program:smsbot_handler]
directory=/home/ubuntu/virt_env/virt1/app/
command=/home/ubuntu/virt_env/virt1/bin/huey_consumer.py main.huey --threads=3
stdout_logfile=/home/ubuntu/smsbot_handler_log.txt
autostart=true
autorestart=true
environment=PYTHONPATH="/home/ubuntu/virt_env/virt1/app:$PYTHONPATH"
redirect_stderr=true
有人能给我一些线索解释为什么这不起作用吗?我在日志文件中得到的全部信息是:

Error importing main.huey

这真的开始困扰我了

假设您已经测试了命令在未从supervisor启动时运行良好,我会删除环境行,转而启动一个shell脚本,设置环境并从shell脚本启动huey_consumer.py(使用exec python)

这就是我对所有需要在主管领导下的特定环境下进行的程序所做的

以下是一个例子:

在管理器配置中:

[program:MyExample]
command=/ama/nms/MyExample/supervisor_myexample.sh
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1                    ; number of processes copies to start (def 1)
directory=/ama/nms/MyExample  ; directory to cwd to before exec (def no cwd)
priority=10                   ; the relative start priority (default 999)
autostart=true                ; start at supervisord start (default: true)
autorestart=true              ; retstart at unexpected quit (default: true)
startsecs=1                   ; number of secs prog must stay running (def. 1)
startretries=10                ; max # of serial start failures (default 3)
exitcodes=0,2                 ; 'expected' exit codes for process (default 0,2)
stopsignal=TERM               ; signal used to kill process (default TERM)
stopwaitsecs=10               ; max num secs to wait b4 SIGKILL (default 10)
在文件/ama/nms/MyExample/supervisor\u MyExample.sh中:

#!/bin/sh
# ------------------------------------------

# Set the environment
export LD_LIBRARY_PATH=<...>:$LD_LIBRARY_PATH
export PYTHONPATH=<...>:$PYTHONPATH

D=`dirname $0`
exec python $D/myexample.py arg1 arg2 arg3
#/垃圾箱/垃圾箱
# ------------------------------------------
#创造环境
导出LD_库路径=:$LD_库路径
导出PYTHONPATH=:$PYTHONPATH
D=`dirname$0`
exec python$D/myexample.py arg1 arg2 arg3

关键是使用exec启动命令,以便supervisor可以监视已启动命令的pid。

如何使用supervisor启动shell脚本?我试过command=script.sh,但似乎不起作用?