-
1. Re: Setting up JBoss as a Linux Service
jonlee Jun 28, 2003 12:27 PM (in response to duncangroenewald)This is a pretty simple init.d script. You can tidy it up a bit, I guess. Call the script /etc/init.d/jboss and use chkconfig to install it so the service starts and stops in the right startup and shutdown sequence when booting and shutting down the OS. "man chkconfig" for more details. I execute run.sh as a background process and look for the JBoss process found with "IBMJava2" - the test could be better constructed and is no guarantee for operation, but it takes a couple of minutes to start JBoss so I don't particularly want to hold up the OS boot process. I'm sure you can polish it up.
#!/bin/sh
#
# chkconfig: - 91 35
# description: Starts and stops the JBoss service.
#
# pidfile: null
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
# Avoid using root's TMPDIR
unset TMPDIR
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
RETVAL=0
start() {
if [ -f /var/lock/subsys/jboss ] ; then
return $RETVAL
fi
KIND="JBoss"
echo -n $"Starting $KIND services: "
cd /usr/local/JBoss-3.2.0/bin
su -p -s /bin/sh -c "./run.sh 2>&1 > run.log &" apache
sleep 3
RETVAL=`ps ax | grep 'IBMJava2' | grep -c -v grep`
if [ $RETVAL -eq 1 ] ; then
touch /var/lock/subsys/jboss
echo_success
else
echo_failure
fi
echo ""
return $RETVAL
}
stop() {
KIND="JBoss"
echo -n $"Shutting down $KIND services: "
cd /usr/local/JBoss-3.2.0/bin
su -p -s /bin/sh -c "./shutdown.sh --" apache
RETVAL=$?
if [ $RETVAL -eq 1 ] ; then
rm -f /var/lock/subsys/jboss
echo_success
else
echo_failure
fi
echo ""
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $? -
2. Re: Setting up JBoss as a Linux Service
mallim Jul 3, 2003 5:12 AM (in response to duncangroenewald)Hi
You can consider using Wrapper (http://wrapper.sourceforge.net) which is applicable for other platforms also.