Hello,
I've just discovered monit, and have been experimenting with it. It
looks like a great application, but I am having a problem starting my
own applications.
I created a wrapper script, since my app doesn't set a PID file. The
script looks like this.
#!/bin/sh
case $1 in
start)
cd /home/eminer/cA3Server
( /home/eminer/cA3Server/cA3Server > /dev/tty6 ) &
pgrep cA3Server > /var/run/cA3Server.pid
;;
stop)
kill `cat /var/run/cA3Server.pid`
rm /var/run/cA3Server.pid
;;
*)
echo "usage: rc.a3server {start|stop}" ;;
esac
I have tried this script with and without the '&' to detach the
process, and monit can't control it either way. I can control the
application from a console using this script, and it works. Using this
script, monit can stop the application, but can't start it. A clip
from my monit log looks like this.
[CST Mar 23 10:50:50] Starting monit daemon with http interface at
[*:443]
[CST Mar 23 10:50:50] Starting monit HTTP server at [*:443]
[CST Mar 23 10:50:50] monit HTTP server started
[CST Mar 23 10:50:56] 'A3Server' stop: /home/eminer/bin/rc.a3server
[CST Mar 23 10:53:25] 'A3Server' stop: /home/eminer/bin/rc.a3server
[CST Mar 23 10:56:45] 'A3Server' stop: /home/eminer/bin/rc.a3server
[CST Mar 23 10:56:51] 'A3Server' start: /home/eminer/bin/rc.a3server
[CST Mar 23 10:56:52] monit: pidfile `/var/run/cA3Server.pid' does not
contain a valid pidnumber
[CST Mar 23 10:56:52] monit: pidfile `/var/run/cA3Server.pid' does not
contain a valid pidnumber
[CST Mar 23 10:56:53] monit: pidfile `/var/run/cA3Server.pid' does not
contain a valid pidnumber
The PID file is recreated at start, but it is empty. Running the start
script manually from a console correctly creates the PID file, with
the proper PID.
Here is a clip of my monitrc file.
check process ssh
with pidfile "/var/run/sshd.pid"
start program = "/etc/rc.d/rc.sshd start"
stop program = "/etc/rc.d/rc.sshd stop"
if 2 restarts within 3 cycles then timeout
check process A3Server
with pidfile "/var/run/cA3Server.pid"
start program = "/home/eminer/bin/rc.a3server start"
stop program = "/home/eminer/bin/rc.a3server stop"
if 2 restarts within 3 cycles then timeout
I can use monit to control ssh perfectly. It may be a problem with my
control script, but I haven't been able to find the problem. I have
searched these archives, but haven't been able to figure this problem
out.
Any help would be appreciated.
Thanks,
Jim Belant