May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

JBOSS AUTO RESTART SCRIPT

JBOSS AUTO RESTART SCRIPT

set –xv

Shell script with Debug command inside:

Add set –xv inside the shell script now to debug the output as shown below.

$ cat filesize.sh
#!/bin/bash
set -xv
for filesize in $(ls -l . | grep “^-” | awk ‘{print $5}’)
do
let totalsize=$totalsize+$filesize
done
echo “Total file size in current directory: $totalsize”

JBOSS AUTO RESTART SCRIPT

#!/bin/sh

#define where jboss is – this is the directory containing directories log, bin, conf etc
JBOSS_HOME=${JBOSS_HOME:-“/apps/appprod/jboss-5.1.0.GA”}

#define the user under which jboss will run, or use ‘RUNASIS’ to run as the current user
JBOSS_USER=${JBOSS_USER:-“prod”}

#make sure java is in your path
JAVAPTH=${JAVAPTH:-“/usr/java/jdk1.6.0_31/bin”}

#configuration to use, usually one of ‘minimal’, ‘default’, ‘all’
JBOSS_CONF=${JBOSS_CONF:-“all”}

#bind jboss services to a specific IP address – added by pmc
JBOSS_HOST=${JBOSS_HOST:-“192.168.1.55″}

#if JBOSS_HOST specified, use -b to bind jboss services to that address
JBOSS_BIND_ADDR=”0.0.0.0″
JBOSS_BIND_ADDR=${JBOSS_HOST:+”-b $JBOSS_HOST”}
#JBOSS_BIND_ADDR=${JBOSS_HOST:+”$JBOSS_HOST”}

#define the classpath for the shutdown class
JBOSSCP=${JBOSSCP:-“$JBOSS_HOME/bin/shutdown.jar:$JBOSS_HOME/client/jnet.jar”}

#define the script to use to start jboss
JBOSSSH=${JBOSSSH:-“$JBOSS_HOME/bin/run.sh -c $JBOSS_CONF $JBOSS_BIND_ADDR -Djboss.service.binding.set=ports-01 -g DocsPartition1”}

if [ “$JBOSS_USER” = “RUNASIS” ]; then
SUBIT=””
else
SUBIT=”su – $JBOSS_USER -c ”
fi

if [ -n “$JBOSS_CONSOLE” -a ! -d “$JBOSS_CONSOLE” ]; then
# ensure the file exists
touch $JBOSS_CONSOLE
if [ ! -z “$SUBIT” ]; then
chown $JBOSS_USER $JBOSS_CONSOLE
fi
fi

if [ -n “$JBOSS_CONSOLE” -a ! -f “$JBOSS_CONSOLE” ]; then
echo “WARNING: location for saving console log invalid: $JBOSS_CONSOLE”
echo “WARNING: ignoring it and using /dev/null”
JBOSS_CONSOLE=”/dev/null”
fi

#define what will be done with the console log
JBOSS_CONSOLE=${JBOSS_CONSOLE:-“/dev/null”}

JBOSS_CMD_START=”cd $JBOSS_HOME/bin; $JBOSSSH”
#JBOSS_CMD_STOP=${JBOSS_CMD_STOP:-“java -classpath $JBOSSCP org.jboss.Shutdown –shutdown”}
#JBOSS_CMD_STOP=”$JAVA_HOME/bin/java -classpath $JBOSSCP org.jboss.Shutdown -s jnp://$JBOSS_BIND_ADDR:1199 –shutdown”
JBOSS_CMD_STOP=”$JAVA_HOME/bin/java -classpath $JBOSSCP org.jboss.Shutdown -s jnp://$JBOSS_HOST:1199 –shutdown”
if [ -z “`echo $PATH | grep $JAVAPTH`” ]; then
export PATH=$PATH:$JAVAPTH
fi

if [ ! -d “$JBOSS_HOME” ]; then
echo JBOSS_HOME does not exist as a valid directory : $JBOSS_HOME
exit 1
fi

echo JBOSS_CMD_START = $JBOSS_CMD_START

case “$1” in
start)
cd $JBOSS_HOME/bin
if [ -z “$SUBIT” ]; then
eval $JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &
else
$SUBIT “$JBOSS_CMD_START >${JBOSS_CONSOLE} 2>&1 &”
fi
;;
stop)
if [ -z “$SUBIT” ]; then
$JBOSS_CMD_STOP
else
$SUBIT “$JBOSS_CMD_STOP”
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo “usage: $0 (start|stop|restart|help)”
esac

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>