monit-general
[Top][All Lists]
Advanced

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

Re: [monit] java daemons


From: Martin Pala
Subject: Re: [monit] java daemons
Date: Thu, 14 Aug 2008 19:25:33 +0200

Hi,

here is short howto in FAQ.txt (http://www.tildeslash.com/monit/doc/faq.php):


3. Q: I have a program that does not create its own pid file. Since
      monit requires all programs to have a pid file, what do I do?

   A: Create a wrapper script and have the script create a pid file
      before it starts the program. Below you will find an example
      script for starting an imaginary program (a Java program in this
      case).  Assuming that the script is saved in a file called
      /bin/xyz, you can call this script from monit by using the
      following in monitrc:

      check process xyz with pidfile /tmp/xyz.pid
        start = "/bin/xyz start"
        stop = "/bin/xyz stop"


          --8<--- (cut here)

          #!/bin/bash
          export JAVA_HOME=/usr/local/java/
          export DISPLAY=localhost:0.0
          CLASSPATH=ajarfile.jar:.

          case $1 in
           start)
           echo $$ > /tmp/xyz.pid;
           exec 2>&1 java -cp ${CLASSPATH} org.something.with.main \
           1>/tmp/xyz.out 
           ;;
          stop)  
           kill `cat /tmp/xyz.pid` ;;
          *)  
           echo "usage: xyz {start|stop}" ;;
          esac
   
          --8<---- (cut here)

the example contains the stop method as well (kill `cat /tmp/xyz.pid`).

Cheers,
Martin

P.S. we plan to add the possibility to control the services without the pidfile need as well (lot of users asked for it).



On Aug 14, 2008, at 11:14 AM, address@hidden wrote:

Hello Martin,

Thanks a lot for your good work.

I work in a VAS company. We have developed a few java daemons.
Monit is based on processID, my daemons do not have pid.
I understand that I should create a rapper scripts

One of my daemons is called, say xyz, locate in /app/japp/
i.e.
/app/japp/xyz.java
/app/japp/xyz.class
/app/japp/error_log
/app/japp/info_log

In my monitrc i should have someting like

check process xyz with pidfile /tmp/xyz.pid
        start = "java /app/japp/xyz"
        stop = "  ???? stop"
I cant figure out how to create
/tmp/xyz.pid and hoe to start or stop it in monit.

with regards
Francis

--
To unsubscribe:
http://lists.nongnu.org/mailman/listinfo/monit-general


reply via email to

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