You are not logged in.

#1 2009-02-23 14:50:43

shiinta
Member
Registered: 2008-12-05
Posts: 11

JBOSS Startup script

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

#2 2009-02-24 07:04:19

drewbug01
Member
From: chicago
Registered: 2007-04-06
Posts: 85
Website

Re: JBOSS Startup script

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

#3 2009-02-24 09:56:22

shiinta
Member
Registered: 2008-12-05
Posts: 11

Re: JBOSS Startup script

Ok cheers for the tips. Going to try it once I get back home to my server

Offline

Board footer

Powered by FluxBB