I managed to make a working init script for JBoss. The
"stop" and "restart" targets work, but I had to make
a modified run.sh to do it. The comments should explain
everything.
/etc/init.d/jbossjetty
-------------------------------------------------------------------
#!/bin/sh
#
# jbossjetty start script for debian init system.
# Save this script as /etc/init.d/jbossjetty, and
# remember to "chmod ugo+x /etc/init.d/jbossjetty".
#
# To make it automatically run on boot,
# cd /etc/rc2.d
# ln -s ../init.d/jbossjetty S90jbossjetty
#
# To make the init system shut it down gracefully
# cd /etc/rc0.d
# ln -s ../init.d/jbossjetty K20jbossjetty
# cd /etc/rc1.d
# ln -s ../init.d/jbossjetty K20jbossjetty
# cd /etc/rc6.d
# ln -s ../init.d/jbossjetty K20jbossjetty
#
# I don't know how many of these link are actually needed.
# I merely copied what the apache package set up. The
# init system probably has a script to make these links,
# but I've always done it manually.
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/var/jbossjetty/jboss/bin/startup.sh
NAME=jbossjetty
PIDFILE=/var/run/jbossjetty.pid
DESC="application server"
test -f $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
#
# -b causes $DAEMON to detach from terminal, running
# in the background.
# -m causes $PIDFILE to be created. (Some demons
# do this themselves, but JBoss won't).
#
# "jetty" (anything after the "--") will be passed
# to $DAEMON as an argument. Normally this would
# have been in the start_with_jetty.sh script in
# the JBoss bin, but I moved it here.
#
start-stop-daemon --start -b -m --pidfile $PIDFILE \
--exec $DAEMON -- jetty
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop -q --oknodo --pidfile $PIDFILE
#
# when using -m to start, start-stop-daemon won't remove $PIDFILE
#
rm $PIDFILE
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop -q --oknodo --pidfile $PIDFILE
rm $PIDFILE
sleep 3
start-stop-daemon --start -q -b -m --pidfile $PIDFILE \
--exec $DAEMON -- jetty
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0
-------------------------------------------------------------------
$JBOSS_HOME/bin/startup.sh
-------------------------------------------------------------------
#!/bin/sh
#
# A modified version of run.sh for use with the init
# script. I saved it in the JBoss bin as "startup.sh"
# and made it executable with "chmod ugo+x startup.sh"
#
# Apparently the run.sh script that comes with the
# distribution assumes it is started when your current
# working directory is the JBoss bin and you type "./run.sh".
# If you're elsewhere and you try to run it with an absolute
# path, like "/var/jbossjetty/jboss/bin/run.sh", JBoss
# blows chunks, at least on my system.
#
# To avoid this, we change directories to the JBoss bin first
# thing...
cd /var/jbossjetty/jboss/bin
#
# Minimal jar file to get JBoss started.
#
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:run.jar
# Add all login modules for JAAS-based security
# and all libraries that are used by them here
JBOSS_CLASSPATH=$JBOSS_CLASSPATH
# Add the XML parser jars and set the JAXP factory names
# Crimson parser JAXP setup(default)
JBOSS_CLASSPATH=$JBOSS_CLASSPATH:../lib/crimson.jar
JAXP=-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.crimson.jaxp.DocumentBuilderFactoryImpl
JAXP="$JAXP
-Djavax.xml.parsers.SAXParserFactory=org.apache.crimson.jaxp.SAXParserFactoryImpl"
# The "exec" bash directive replaces the shell process with
# the java process, keeping the same PID. This allows the
# /etc/init.d/jbossjetty "stop" and "restart" arguments to work.
# Without the exec, SIGTERM would kill this script but leave
# the java process alive. With the exec, SIGTERM is sent
# directly to the java process.
#
# Note that we are also redirecting the log to somewhere useful.
# Don't forget to "mkdir /var/log/jbossjetty"
#
exec /usr/local/jdk1.3/bin/java -server $JAXP -classpath $JBOSS_CLASSPATH
org.jboss.Main $@ 2>&1 >> /var/log/jbossjetty/console
-------------------------------------------------------------------
----
[EMAIL PROTECTED]
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user