#!/usr/bin/sh # PRG="$0" # check if the file: startXXX.sh or stopXXX.sh is symbolic link # while [ -h "$PRG" ]; do # ls = `ls -ld "$PRG"` # echo $ls # link = `expr "$ls" : '.*-> \(.*\)$'` # if expr "$link" : '/.*' > /dev/null; then # PRG="$link" # else # PRG=`dirname "$PRG"`/"$link" # fi # done # get $WMS_HOME/bin directory PRGDIR=`dirname "$PRG"` # initial WMS_HOME when WMS_HOME is not set [ -z "$WMS_HOME" ] && WMS_HOME=`cd "$PRGDIR/.." >/dev/null; pwd` # initial WMS_BASE when WMS_BASE is not set [ -z "$WMS_BASE" ] && WMS_BASE="$WMS_HOME" ACTION=$1 SVR=$2 SEQNUM=$3 JMXPORT=$4 HTTPPORT=$5 xms=$6 xmx=$7 workerWeight=$8 workerTasks=$9 schedulerWeight=${10} CLASSPATH=$CLASSPATH dq=${11} echo "Using Prameter: ACTION=$ACTION SVR=$SVR SEQNUM=$SEQNUM JMXPORT=$JMXPORT HTTPPORT=$HTTPPORT xms=$xms xmx=$xmx workerWeight=$workerWeight workerTasks=$workerTasks schedulerWeight=$schedulerWeight CLASSPATH=$CLASSPATH dq=$dq"; echo "Using WMS_HOME: $WMS_HOME"; case $WMS_HOME in *:*) echo "Unable to start as WMS_HOME contains a colon (:) character"; exit 1; esac echo "Using WMS_BASE: $WMS_BASE"; case $WMS_BASE in *:*) echo "Unable to start as WMS_BASE contains a colon (:) character"; exit 1; esac if [[ `hostname` = 'ap1' ]] then SEQ="$SVR"1"$SEQNUM" elif [ `hostname` = 'ap2' ] then SEQ="$SVR"2"$SEQNUM" elif [ `hostname` = 'ap3' ] then SEQ="$SVR"3"$SEQNUM" else SEQ="$SVR"1"$SEQNUM" fi if [ -z "$WMS_TMPDIR" ]; then WMS_TMPDIR="$WMS_BASE"/temp fi if [ ! -d "$WMS_TMPDIR/$SEQ" ] ; then echo '$SEQ='$SEQ mkdir -p "$WMS_TMPDIR/$SEQ" fi svrPrivateDir="$WMS_TMPDIR/$SEQ" #echo "svrPrivateDir="$svrPrivateDir if [ -z "$WMS_PID" ]; then WMS_PID="$WMS_TMPDIR"/"$SEQ"/wms.run fi if [ $ACTION = 'start' ] || [ $ACTION = 'run' ] ; then if [ -r "$WMS_BASE"/bin/setenv.sh ]; then . "$WMS_BASE"/bin/setenv.sh $SVR $SEQNUM $6 $7 fi if [ -r "$WMS_HOME"/bin/setclasspath.sh ]; then . "$WMS_HOME"/bin/setclasspath.sh else echo "cann't find $WMS_HOME/bin/setclasspath.sh" echo "This file is needed to run this project" exit 1 fi if [ ! -z "$CLASSPATH" ] ; then CLASSPATH="$CLASSPATH":.: fi if [ -z "$WMS_OUT" ] ; then WMS_OUT="$WMS_BASE"/logs/"$SEQ".out fi if [ -z "$MAINCLASS" ] ; then MAINCLASS="$svrPrivateDir"/bootstrap.jar fi #echo "MAINCLASS="$MAINCLASS if [ -a "$MAINCLASS" ] ; then rm -f "$MAINCLASS" echo "delete $MAINCLASS" fi cp "$WMS_BASE"/lib/bootstrap.jar "$svrPrivateDir"/ echo "copy $WMS_BASE/lib/bootstrap.jar to $svrPrivateDir/" if [ -z "$SPRING_CONFIG_LOCAL" ] ; then SPRING_CONFIG_LOCAL="$WMS_BASE"/conf/profile/application-${SVR%"svr"}.yml fi if [ -z "$UMASK" ]; then UMASK="0027" fi umask $UMASK if [ -z "$USE_NOHUP" ] ; then USE_NOHUP="true" fi unset _NOHUP if [ "$USE_NOHUP" = "true" ] ; then _NOHUP="nohup" fi have_tty=0 if [ -t 0 ]; then have_tty=1 fi if [ $have_tty -eq 1 ]; then echo "Using WMS_HOME: $WMS_HOME" echo "Using WMS_BASE: $WMS_BASE" echo "Using WMS_TMPDIR: $WMS_TMPDIR" echo "Using JAVA_HOME: $JAVA_HOME" echo "Using CLASSPATH: $CLASSPATH" echo "Using WMS_OUT: $WMS_OUT" if [ ! -z "$WMS_PID" ]; then echo "Using WMS_PID: $WMS_PID" fi fi if [ $ACTION = "run" ] ; then shift echo "$_RUNJAVA -jar $WMS_OPTS $JAVA_OPTS -Dcom.sun.management.jmxremote.port=$JMXPORT -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dhttp.port=$HTTPPORT -Dwms.home=$WMS_HOME -Djava.io.tmpdir=$WMS_TMPDIR -Dspring.config.location=$SPRING_CONFIG_LOCAL $MAINCLASS $@ start" eval exec "\"$_RUNJAVA\"" " -jar " $WMS_OPTS \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=$JMXPORT \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Djmx.port=$JMXPORT \ -Dhttp.port=$HTTPPORT \ $JAVA_OPTS \ -Dwms.home="\"$WMS_HOME\"" \ -Djava.io.tmpdir="\"$WMS_TMPDIR\"" \ -Dspring.config.location="\"$SPRING_CONFIG_LOCAL\"" \ "$MAINCLASS" "$@" start elif [ $ACTION = "start" ]; then if [ -f "$WMS_PID" ]; then if [ -s "$WMS_PID" ]; then echo "Existing PID file found during start." if [ -r "$WMS_PID" ]; then PID=`cat "$WMS_PID"` ps -p $PID >/dev/null 2>&1 if [ $? -eq 0 ] ; then echo "WMS appears to still be running with PID $PID. Start aborted." echo "If the following process is not a WMS process, remove the PID file and try again:" ps -f -p $PID exit 1 fi fi fi fi shift # touch "$WMS_OUT" echo "$_NOHUP $_RUNJAVA -jar $WMS_OPTS $JAVA_OPTS -Dcom.sun.management.jmxremote.port=$JMXPORT -Dhttp.port=$HTTPPORT -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dwms.home=$WMS_HOME -DworkerTasks=$workerTasks -Ddq=$dq -DdataField=Message -DworkerWeight=$workerWeight -DschedulerWeight=$schedulerWeight -Djava.io.tmpdir=$WMS_TMPDIR -Dspring.config.location=$SPRING_CONFIG_LOCAL $MAINCLASS $@ start" eval $_NOHUP "\"$_RUNJAVA\"" " -jar " \ "$WMS_OPTS" \ -Dcom.sun.management.jmxremote \ -Dcom.sun.management.jmxremote.port=$JMXPORT \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -Djmx.port=$JMXPORT \ -Dhttp.port=$HTTPPORT \ $JAVA_OPTS \ -DworkerWeight=$workerWeight \ -DworkerTasks=$workerTasks \ -DschedulerWeight=$schedulerWeight \ -Ddq=$dq \ -DdataField=Message \ -Dwms.home="\"$WMS_HOME\"" \ -Djava.io.tmpdir="\"$WMS_TMPDIR\"" \ -Dspring.config.location="\"$SPRING_CONFIG_LOCAL\"" \ "$MAINCLASS" "$@" start \ >> /dev/null 2>&1 "&" fi elif [ $ACTION = "version" ] ; then echo "version : WMS Server 1.0.0" else echo "Usage: bidmboot.sh ( commands ... )" echo "commands:" echo " run Start WMS AP Server in the current window" echo " start Start WMS AP Server in a separate window" echo " stop Stop WMS AP Server, waiting up to 5 seconds for the process to end" echo " stop n Stop WMS AP Server, waiting up to n seconds for the process to end" echo " stop -force Stop WMS AP Server, wait up to 5 seconds and then use kill -KILL if still running" echo " stop n -force Stop WMS AP Server, wait up to n seconds and then use kill -KILL if still running" echo " version What version of WMS are you runing?" echo "Note: Waiting for the process to end and use of the -force option require that \$WMS_PID is defined" exit 1 fi