How to add a delay to supervised process in supervisor - linux
Solution 1
Not happy enough with the sleep
hack I created a startup script and launched supervisorctl start processname
from there.
[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
This way supervisor will fire the startup script once and this will start myapp after 5 seconds, mind the autostart=false
and autorestart=true
on myapp
.
Solution 2
This is what I use:
[program:uwsgi]
command=bash -c 'sleep 5 && uwsgi /etc/uwsgi.ini'
Zack S
Finished my CS degree in 2014,and couldn't wish for a better field. I always had high curiosity and excitement to solve problems while learning new technologies! In the meantime I work with Apache products: Kafka, Storm, Cassandra / mqtt / Node.js / Angularjs / MongoDB / HTML5 / Linux / and whatever is needed to complete my tasks.I hope, in the future, to be a meaningful contributor to this awesome community.
Updated on July 27, 2022Comments
-
Zack S almost 2 years
I added a bottle server that uses python's cassandra library, but it exits with this error:
Bottle FATAL Exited too quickly (process log may have details)
log shows this:
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)
So I tried to run it manually using supervisorctl start Bottle ,and then it started with no issue. The conclusion= Bottle service starts too fast (before the needed cassandra supervised service does): a delay is needed! -
Slotos almost 9 years
command=bash -c "sleep 5 && exec uwsgi /etc/uwsgi.ini"
: exec will replace bash with uwsgi, double quotes will ensure that enclosed string will be sent to bash as a single argument. -
kgreenek over 6 yearsWhen I do this, the process keeps running in the background after i do "supervisorctl stop"
-
Torsten Bronger over 4 years@kgreenek Yes, and the previous comment will fix that. Unless your actual program is broken.