I'm trying to use monit to monitor a java process. The monit file for the process is as follows:
check process xyz pidfile /tmp/xyz.pid
start program = "/bin/bash -c 'source /home/.bashrc; source /home/xyzprog/setup.sh; /home/xyzprog/xyz start'"
stop program = "/bin/bash -c '/home/xyzprog/xyz stop'"
This process works fine if i start with with
sudo monit start xyz
But fails completely if when i start monit in daemon mode.
Anyone know what the problem might be?
Okay, so I realized that some of the scripts were based on running in the home directory of the process, so i update the start program to the follow:
check process xyz pidfile /tmp/xyz.pid
start program = "cd /home/xyzprog; /bin/bash -c 'source /home/.bashrc; source /home/xyzprog/setup.sh; /home/xyzprog/xyz start'"
stop program = "/bin/bash -c '/home/xyzprog/xyz stop'"
if failed host 192.168.1.103 port 8080 protocol http with timeout 20 seconds for 1 cycle then restart
I simply added 'cd /home/xyzprog' to the start program and it worked! I killed the process and it came right back.