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

Zac*_*k S 9 python linux cassandra bottle supervisord

我添加了一个使用python的cassandra库的瓶子服务器,但它退出时出现此错误:
Bottle FATAL Exited too quickly (process log may have details)
log显示:
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监督服务之前):需要延迟!

Dee*_*eeY 19

这是我使用的:

[program:uwsgi]
command=bash -c 'sleep 5 && uwsgi /etc/uwsgi.ini'
Run Code Online (Sandbox Code Playgroud)

  • `command = bash -c"sleep 5 && exec uwsgi /etc/uwsgi.ini"`:exec将用uwsgi替换bash,双引号将确保包含的字符串将作为单个参数发送给bash. (13认同)
  • 当我执行此操作时,在执行"supervisorctl stop"后,该过程在后台继续运行 (3认同)
  • @kgreenek 是的,之前的评论将解决这个问题。除非你的实际程序被破坏了。 (2认同)

MGP*_*MGP 6

sleephack不够满意,我创建了一个启动脚本并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
Run Code Online (Sandbox Code Playgroud)

启动文件

#!/bin/bash
sleep 5
supervisorctrl start myapp
Run Code Online (Sandbox Code Playgroud)

这样,主管将触发启动脚本一次,这将在5秒后开始MYAPP,介意autostart=falseautorestart=truemyapp