Reputation: 35
I have a python script sc.py on my debian server.
I would like :
Do you know software that would enable me to do so?
I don't know if I have to look for a solution on the python side (any python module or configuration) or if there is a debian package somewhere which does that job?
Upvotes: 1
Views: 628
Reputation: 6144
Another process manager I stumbled upon is circus
.
It looks more adventurous, if that's your thing ;)
And the web interface is richer than supervisord's: See some nice screenshots.
Upvotes: 1
Reputation: 6144
If this is a one-time task (that is, you are not creating a software product) I would quick-and-dirty use a combination of shell scripting and a terminal multiplexer like screen. For restarting processes that died (that is, they emitted an exit code other than 0
), just use the shell.
Start your processes for example like this:
for i in n/*; do
screen -d -m -L -S $i -t $i until python sc.py $i; do echo "Crashed with exit code $?. Respawning.." >&2 ; sleep 1 ; done
done
This would
n/
running your script,until
)-t
) and session name (-S
) to the input file name,-L
).You can then use normal screen commands like screen -list
to list all running tasks and screen -r <session name>
to view the running session output.
Upvotes: 1
Reputation: 39013
You can use supervisord
for this.
It daemonizes Python processes for you, and also handles subprocesses.
Upvotes: 2