Closed jimdoesvoip closed 7 years ago
I assume that perhaps no one reading the issues has done this or done it recently.
We did end up writing a functional init script for this. We've setup and tested on CentOS6, so assume it will work on other distros, but pre-systemd distros. Thanks Jamie for the help in finishing and fixing what I started.
Here is what we've used. Note that this supports adding to chkconfig which is always nice.
PGREP=/usr/bin/pgrep PKILL=/usr/bin/pkill JAVA=/usr/bin/java
start() { echo "Starting logsniffer..."
$PGREP -f logsniffer.war > /dev/null
VERIFIER=$?
if [ $VERIFIER == 0 ]
then
echo "The service is already running"
else
#Run the jar file logsniffer service
$JAVA -jar /root/logsniffer.war > /dev/null 2>&1 &
#sleep time before the service verification
#sleep 10
#Verify if the service is running
$PGREP -f logsniffer.war > /dev/null
VERIFIER=$?
if [ $VERIFIER == 0 ]
then
echo "Service was successfully started"
else
echo "Failed to start service"
fi
fi
echo
}
stop() { echo "Stopping logsniffer..."
$PKILL -f logsniffer.war
VERIFIER=$?
if [ $VERIFIER == 0 ]
then
echo "Service stopped"
elif [ $VERIFIER == 1 ]
then
echo "Service already stopped"
else
echo "pkill error: $VERIFIER"
fi
}
status() { echo "Checking status of logsniffer..."
$PGREP -f logsniffer.war
VERIFIER=$?
if [ $VERIFIER == 0 ]
then
echo "Service is running"
else
echo "Service is stopped"
fi
echo
}
case "$1" in start) start ;; stop) stop ;; status) status ;; restart|reload) stop start ;; *) echo $"Usage: $0 {start|stop|status|restart|reload}" exit 1 esac exit 0 #
Has anyone written a init script (Centos/RHEL 6 style) for logsniffer?