|
From: | Andreas Theissen |
Subject: | Deamons, Pids and Wrappers |
Date: | Thu, 24 Mar 2011 13:16:16 +0100 |
User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 |
... and final reply on Vol 98, Issue 18 (wrong quotes) first of all thank you again for that quick answer to my silly question. I must have been too tired that that day, so I simply copied these wrong quotes from anywhere . As you wrote, of course monit is plain sailing now and gracefully monitors anything via web interface , which has a pid-file in /var/run, for example. Besides that I've also configered a very basic iptables firewall script, which is also runs fine, and which can be started and stopped either in /etc/init.d/ or runlevel based (I achieved the latter by using update-rc.d). The script looks like: #! /bin/bash ### BEGIN INIT INFO # Provides: myFirewall # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start myFirewall or so at boot time # Description: Enable service provided by myFirewall. ### END INIT INFO ECHO="/bin/echo" SYSCTL="/sbin/sysctl" IPTABLES="/sbin/iptables" # Firewall Rules and so on... esac exit 0 Though the script runs perfectly, monit can't monitor the deamon, as it doesn't generate a pidfile itself in /var/run or anywhwere else. In the Monit-FAQ (http://mmonit.com/wiki/Monit/FAQ ) I found some advice to configurate a wrapper, which generates the pidfile for a specific Applications (Java&tm; in that case). #!/bin/bash export JAVA_HOME=/usr/local/java/ CLASSPATH=ajarfile.jar:. case $1 in start) echo $$ > /var/run/xyz.pid; exec 2>&1 java -cp ${CLASSPATH} org.something.with.main 1>/tmp/xyz.out ;; stop) kill `cat /var/run/xyz.pid` ;; *) echo "usage: xyz {start|stop}" ;; esac exit 0 I simply wonder how to make this work for my little idiot's firewall deamon somehow - especially concerning the line with the ugly 'exec' in front. Though it is a very beginner's problem again, maybe more generalized examples in your FAQ could also be a good idea to prevent fools like me from wasting your time :) best regards Andreas |
[Prev in Thread] | Current Thread | [Next in Thread] |