I'm trying to get monit to monitor a program and start it if it goes down. Here's my basic config:
check process maitre_d_8000 with pidfile /home/tango/env/maitre_d/8000/pid.pid
start program = "/bin/bash -c 'cd /home/tango/env/maitre_d/; ../bin/python maitre_d/main.py 8000/config.json &'" as uid tango and gid tango
stop program = "/bin/bash -c 'cd /home/tango/env/maitre_d/; ../bin/python kill.py 8000/pid.pid'" as uid tango and gid tango
However, whenever I kill the program, I get this in the logs:
[EDT Apr 17 21:30:25] error : 'maitre_d_8000' process is not running
[EDT Apr 17 21:30:27] info : 'maitre_d_8000' trying to restart
[EDT Apr 17 21:30:27] info : 'maitre_d_8000' start: /bin/bash
[EDT Apr 17 21:30:57] error : 'maitre_d_8000' failed to start
Not very helpful at all. And the bash command should work just fine, running su tango -c "/bin/bash -c 'cd /home/tango/env/maitre_d/; ../bin/python maitre_d/main.py 8000/config.json &'"
in the terminal results in successfully starting the program.
Any ideas of what could be going wrong?
With help from this answer, I was able to figure out what was going on: Python was encountering a MemoryError.