假设您已经测试过您的命令在未从主管启动时运行良好,我将删除环境行,改为启动 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_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
关键是使用 exec 启动命令,以便主管可以监视启动的命令的 pid。