I want my python program sample.py to be always up and running. I have read some things and asked people about ways to do this. So far I have following options -
I am trying things with upstart right now. I have created a sample.conf in
#sample.conf description "gearmanWorker1" author "hussain" pre-start script logger "pre-start for sample" end script post-start script logger "post-start for sample" end script script logger "just before executing sample.sh" exec /usr/bin/python /home/magic/Documents/gearman-python/Worker.py end script
But when I do
sudo initctl start sample /
sudo start sample it says -
start: Unknown job: sample
When I do
status sample, it says -
which means sample process is not running yet.
I don't know if I am doing this right; I am very new to this. Also I don't think cron will be the best way to achieve what I want. Because I just want to monitor sample in such a way that it will automatically restart after a failure/abort. It should also restart after a reboot.
Also feel free to suggest any other better ways to do this.