Jboss Startup Script for Managing Server

Jboss or Wildfly

Below given jboss startup script can be used to manage Jboss application Server life cycle like stop, start and status of Jboss process.

1.     Create a file named jboss.sh at /opt/ or any other easy to access location and put all the below given text exactly in to the file.

2.    Set/change JBOSS_ROOT to your JBoss installation root.

3.    Set/change ADMIN_PORT port number to JBoss Admin server listening port.

4.    Set/Change ADMIN_USERNAME and ADMIN_PASSWORD to admin user name and admin user password.

5.    Change the PROFILE to your required profile(minimal, default, all, production) and RMI_PORT to the servers RMI_PORT(Default: 1099)

6.    Give execute permission to jboss.sh script.(E.g.: chmod 0755 jboss.sh)

7.    Use below commands to check the status, stop and start JBoss Server.

./jboss.sh status
./jboss.sh start
./jboss.sh stop


Script:

 

#!/bin/sh
#JBOSS start and stop script.
#rks2286(at)gmail(dot)com
#Sample script start and stop for jboss:
#-----------------------
#Changable texts JBOSS_ROOT, ADMIN_USERNAME, ADMIN_PASSWD, ADMIN_PORT, RMI_PORT, PROFILE.
#-----------------------
JBOSS_ROOT=/opt/jboss-eap-4.3/jboss-as/
ADMIN_USERNAME=admin
ADMIN_PASSWD=jbossadm
ADMIN_PORT=8080
RMI_PORT=1099
PROFILE=all
#---------------------
#JBOSS StartUp.....
#---------------------
export CLASSPATH
start() {
echo Starting jboss...;
echo Wait while the jboss server starts...;
$JBOSS_ROOT/bin/run.sh -c $PROFILE -b 0.0.0.0 > /tmp/null &
}
#-------------------
#JBOSS shutdown.....
#-------------------

stop() {
echo Stopping jboss..;
echo Wait while the jboss server stops;
$JBOSS_ROOT/bin/shutdown.sh -s `hostname`:$RMI_PORT -u $ADMIN_USERNAME -p $ADMIN_PASSWD &
}
status() {
echo Checking JBoss Status..
echo Wait for a while...
_up=`netstat -an | grep $ADMIN_PORT | grep -v grep | wc -l`

if [[ "${_up}" != "0" ]]; then
echo "###############################################"
echo "JBoss Application Server is Up!! And Running.!!"
echo "###############################################"
else
echo "##################################"
echo "JBoss Application Server is Down!!"
echo "##################################"
fi;
}

if [[ "${1}" == "start" ]];
then
start
elif [[ "${1}" == "stop" ]];
then
stop
elif [[ "${1}" == "status" ]];
then
status
else
echo "####################################################"
echo Usage:
echo export JBOSS_ROOT=Path_To_Root_Folder
echo .\/\jboss.sh start\|\stop;
echo Example:
echo export JBOSS_ROOT=\/\opt\/\jboss-eap-4.3\/\jboss-as;
echo ./jboss.sh start\|\stop;
echo "####################################################"
fi;
exit 0;

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

2 Responses

  1. It is a nice article, thanks for sharing the information.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.