While working on remote servers and running JBoss AS on it, sometimes gives hard bite to manage.
What if you encounter mentioned problems after starting JBoss AS:-
Connection lost to remote server?
Power failure at your end?
Connection failure at your end?
And what if you don't want to stop JBoss AS at remote server but you have to turn off your local system from where you have given command like ./run.sh -b xxx.yyy.zzz.aaa ?
JBoss instance would be running on remote server until you force fully kill it after getting back your connectivity.
Solution for this is Create JBoss SERVICE to run and stop :)
Now how to do that
1> /etc/init.d/ - contains the start and stop scripts (other distributions: /etc/init.d/), create a Start and Stop script for JBoss and as ROOT make your script executable use this command "chmod 755 /etc/rc.d/init.d/jboss"
2> /etc/rc.(x)/ - contains links to the start and stop scripts prefixed with S or K (start or kill respectively)
There are various run levels for various stages of system use.
1.rc1.d - Single User Mode
2.rc2.d - Single User Mode with Networking
3.rc3.d - Multi-User Mode - boot up in text mode
4.rc4.d - Undefined
5.rc5.d - Multi-User Mode - boot up in X Windows
6.rc6.d - Shutdown
Create a symbolic link to respective rc(x)
Now in detail, follow the commands (assuming you are running it on remote server)
1> cd /etc/init.d
2> vi jboss
3> press Esc and i(to insert)
add following code in it
start()
{
echo "*************Starting JBoss************"
/home/Sachin/JBoss/bin/run.sh -b xxx.yyy.zzz.aaa > /dev/null 2> /dev/null &
sleep 60
echo "************* Started *****************"
}
stop(){
echo "************* Halting JBoss ************"
/home/Sachin/JBoss/bin/shutdown.sh --server=xxx.yyy.zzz.aaa &
sleep 60
echo "************* JBoss Halted ************"
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: jboss {start|stop}"
exit 1
esac
exit 0
now exit by typing Esc and :wq!
4> type chmod 755 /etc/rc.d/init.d/jboss to make your script executable
5> run following commands as root user
ln -s /etc/init.d/jboss /etc/rc3.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc5.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc4.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc6.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc0.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc1.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc2.d/K15jboss
Thats all we are done
now try
service jboss start
service jboss stop
What if you encounter mentioned problems after starting JBoss AS:-
Connection lost to remote server?
Power failure at your end?
Connection failure at your end?
And what if you don't want to stop JBoss AS at remote server but you have to turn off your local system from where you have given command like ./run.sh -b xxx.yyy.zzz.aaa ?
JBoss instance would be running on remote server until you force fully kill it after getting back your connectivity.
Solution for this is Create JBoss SERVICE to run and stop :)
Now how to do that
1> /etc/init.d/ - contains the start and stop scripts (other distributions: /etc/init.d/), create a Start and Stop script for JBoss and as ROOT make your script executable use this command "chmod 755 /etc/rc.d/init.d/jboss"
2> /etc/rc.(x)/ - contains links to the start and stop scripts prefixed with S or K (start or kill respectively)
There are various run levels for various stages of system use.
1.rc1.d - Single User Mode
2.rc2.d - Single User Mode with Networking
3.rc3.d - Multi-User Mode - boot up in text mode
4.rc4.d - Undefined
5.rc5.d - Multi-User Mode - boot up in X Windows
6.rc6.d - Shutdown
Create a symbolic link to respective rc(x)
Now in detail, follow the commands (assuming you are running it on remote server)
1> cd /etc/init.d
2> vi jboss
3> press Esc and i(to insert)
add following code in it
start()
{
echo "*************Starting JBoss************"
/home/Sachin/JBoss/bin/run.sh -b xxx.yyy.zzz.aaa > /dev/null 2> /dev/null &
sleep 60
echo "************* Started *****************"
}
stop(){
echo "************* Halting JBoss ************"
/home/Sachin/JBoss/bin/shutdown.sh --server=xxx.yyy.zzz.aaa &
sleep 60
echo "************* JBoss Halted ************"
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo "Usage: jboss {start|stop}"
exit 1
esac
exit 0
now exit by typing Esc and :wq!
4> type chmod 755 /etc/rc.d/init.d/jboss to make your script executable
5> run following commands as root user
ln -s /etc/init.d/jboss /etc/rc3.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc5.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc4.d/S84jboss
ln -s /etc/init.d/jboss /etc/rc6.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc0.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc1.d/K15jboss
ln -s /etc/init.d/jboss /etc/rc2.d/K15jboss
Thats all we are done
now try
service jboss start
service jboss stop
No comments:
Post a Comment