monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application fails to start.


From: Jan-Henrik Haukeland
Subject: Re: Application fails to start.
Date: Sat, 26 Mar 2005 02:00:42 +0100

This is not good:

    ( /home/eminer/cA3Server/cA3Server > /dev/tty6 ) &
    pgrep cA3Server > /var/run/cA3Server.pid

This means that the shell will start the cA3Server in a new sub-process and the control jumps immediately to the pgrep command. In other words the pgrep command may finnish before the cA3Server was started. This should explain why you got an empty value in the pid file. Use the exec statement to start the server and *do not* put the server in the background, monit does this automatically when it calls the script. See also the startup script example in the FAQ.


jbelant wrote:
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

--
Jan-Henrik Haukeland
Mobil +47 97141255





reply via email to

[Prev in Thread] Current Thread [Next in Thread]