You are not logged in.
Pages: 1
Hey I'm trying to create a startup script for my jboss server. The server starts up, but when I run /etc/rc.d/jboss it shows DONE as soon as the script is run. How can I make it wait untill the jboss server is up before it's printing done?
So it says BUSY untill the servers is fully up and running and then says DONE
#!/bin/bash
. /etc/rc.d/functions
PID=`pidof -o %PPID /opt/jboss-5.0.0.GA/bin/run.sh`
case "$1" in
start)
stat_busy "Starting JBOSS"
[ -z "$PID" ] && /opt/jboss-5.0.0.GA/bin/run.sh > /dev/null 2> /dev/null &
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon JBOSS
stat_done
fi
;;
stop)
stat_busy "Stopping JBOSS"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon JBOSS
stat_done
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Offline
Simple answer is to not background the process.
When you do :
[ -z "$PID" ] && /opt/jboss-5.0.0.GA/bin/run.sh > /dev/null 2> /dev/null &
the ampersand (&) causes that process to fork off in the background and it immediately goes to the next statment without waiting for JBOSS to actually start. So, removing the ampersand will cause it to wait untill the JBOSS script finishes, and then do the test for completion.
Now, without seeing the "/opt/jboss-5.0.0.GA/bin/run.sh" script, I don't know if removing the "&" will cause your boot to hang. I'm assuming that the run.sh backgrounds the JBOSS processes and exits on successful startup, but you'll want to make sure that it indeed does that.
Hope this helps!
-- Drew
Offline
Ok cheers for the tips. Going to try it once I get back home to my server
Offline
Pages: 1