如何在supervisor中为监督进程添加延迟 - linux

时间:2014-10-13 14:43:31

标签: python linux cassandra bottle supervisor

我添加了一个使用python的cassandra库的瓶子服务器,但它退出时出现此错误:
Bottle FATAL Exited too quickly (process log may have details)
日志显示:
File "/usr/local/lib/python2.7/dist-packages/cassandra/cluster.py", line 1765, in _reconnect_internal raise NoHostAvailable("Unable to connect to any servers", errors)

所以我尝试使用supervisorctl start Bottle手动运行它,然后开始没有问题。结论=瓶子服务开始得太快(在需要的cassandra监督服务之前):需要延迟!

2 个答案:

答案 0 :(得分:17)

这就是我使用的:

[program:uwsgi]
command=bash -c 'sleep 5 && uwsgi /etc/uwsgi.ini'

答案 1 :(得分:2)

我对sleep hack感到不满意,我创建了一个启动脚本并从那里启动了supervisorctl start processname

[program:startup]
command=/startup.sh
startsecs = 0
autostart = true
autorestart = false
startretries = 1
priority=1

[program:myapp]
command=/home/website/venv/bin/gunicorn /home/website/myapp/app.py
autostart=false
autorestart=true
process_name=myapp

startup.sh

#!/bin/bash
sleep 5
supervisorctrl start myapp

这样,主管将触发一次启动脚本,这将在5秒后启动myapp,请注意autostart=false上的autorestart=truemyapp