Creating a Unix Service for ActiveMQBelow are steps to make ActiveMQ a Linux Daemon on Red Hat 4 ES. It's based on this article Alternatively, you could also use the Java Service Wrapper implementation, refer to the Java Service Wrapper Page for more details. SettingsJAVA_HOME = /opt/java/jdk1.5.0_06 ActiveMQ = /opt/activemq/incubator-activemq-4.0 InstallationSun Java JDK 1. Install Sun Java JDK on /opt/java/ directory. 2. Create a shortcut to JDK directory: sudo ln -s /opt/java/jdk1.5.0_06 /opt/java/java ActiveMQ 1. Install ActiveMQ on /opt/activemq/ directory. 2. Make ActiveMQ startup and shutdown scripts executable: sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/activemq sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/shutdown ActiveMQ as Linux Daemon 1. Create activemq user: sudo /usr/sbin/useradd activemq 2. Create ActiveMQ startup script /home/activemq/activemqstart.sh with the #!/bin/bash export JDK_HOME=/opt/java/java export JAVA_HOME=/opt/java/java /opt/activemq/incubator-activemq-4.0/bin/activemq & 3. Make /home/activemq/activemqstart.sh executable: sudo chmod +x /home/activemq/activemqstart.sh 4. Create ActiveMQ shutdown script /home/activemq/activemqstop.sh with the #!/bin/bash export JDK_HOME=/opt/java/java export JAVA_HOME=/opt/java/java /opt/activemq/incubator-activemq-4.0/bin/shutdown 5. Make /home/activemq/activemqstop.sh executable: sudo chmod +x /home/activemq/activemqstop.sh 6. Create ActiveMQ Linux service configuration script /etc/init.d/activemq #!/bin/bash
#
# activemq Starts ActiveMQ.
#
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: $activemq
### END INIT INFO
# Source function library.
. /etc/init.d/functions
[ -f /home/activemq/activemqstart.sh ] || exit 0
[ -f /home/activemq/activemqstop.sh ] || exit 0
RETVAL=0
umask 077
start() {
echo -n $"Starting ActiveMQ: "
daemon /home/activemq/activemqstart.sh
echo
return $RETVAL
}
stop() {
echo -n $"Shutting down ActiveMQ: "
daemon su -c /home/activemq/activemqstop.sh activemq
echo
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
7. Enable ActiveMQ service configuration as Linux Daemon: sudo chmod +x /etc/init.d/activemq sudo /sbin/chkconfig --add activemq sudo /sbin/chkconfig activemq on 8. Restart the server. Note: activemq-data is being created in "/" root directory. I have to |