Authored by ming

fix

#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-29
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
TIMESTAMP=`date +%Y_%m_%d_%H_%M`
LOG_DIR=$WEB_APP_HOME/logs
LOGS_SAVED=$LOG_DIR/logs_saved
JBOSS_STDOUT_LOG=$LOG_DIR/jboss_stdout.log
JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default
#################################################################
#backup logs
if [ ! -d $LOGS_SAVED ]; then
mkdir -p $LOGS_SAVED
fi
if [ -f $JBOSS_STDOUT_LOG ]; then
mv -f $JBOSS_STDOUT_LOG $LOGS_SAVED/jboss_stdout.log.$TIMESTAMP
fi
##check if started before
java_pid=`ps --no-heading -C java -f --width 1000 | grep "$JBOSS_BASE_DIR" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
echo "Jboss server already started: pid=$java_pid"
exit;
fi
#########################################copy server home
if [ ! -d "$JBOSS_BASE_DIR" ]; then
rm -f $JBOSS_BASE_DIR
mkdir -p $JBOSS_BASE_DIR
cp -rf $SERVER_HOME/standalone/. $JBOSS_BASE_DIR/.
else
rm -rf $JBOSS_BASE_DIR/tmp
rm -rf $JBOSS_BASE_DIR/data
rm -rf $JBOSS_BASE_DIR/log
fi
deploy
##jmx controle file must be read only else jvm can not startup
chmod 600 $WEB_APP_HOME/conf/jmx/*.properties > /dev/null 2>&1
nohup $SERVER_HOME/bin/standalone.sh
################################################################
copy_jboss_conf(){
cp -rf $WEB_APP_HOME/conf/jboss/standalone.xml $JBOSS_BASE_DIR/configuration/standalone.xml
}
deploy_ear(){
rm -rf $JBOSS_BASE_DIR/deployments/web.ear
rm -rf $JBOSS_BASE_DIR/deployments/web.ear.*
cp -rf $JBOSS_BASE_DIR/web.ear $JBOSS_BASE_DIR/deployments/web.ear
touch $JBOSS_BASE_DIR/deployments/web.ear.dodeploy
}
deploy(){
copy_jboss_conf
deploy_ear
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-29
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
TIMESTAMP=`date +%Y_%m_%d_%H_%M`
LOG_DIR=$WEB_APP_HOME/logs
LOGS_SAVED=$LOG_DIR/logs_saved
JBOSS_STDOUT_LOG=$LOG_DIR/jboss_stdout.log
JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default
#################################################################
#backup logs
if [ ! -d $LOGS_SAVED ]; then
mkdir -p $LOGS_SAVED
fi
if [ -f $JBOSS_STDOUT_LOG ]; then
mv -f $JBOSS_STDOUT_LOG $LOGS_SAVED/jboss_stdout.log.$TIMESTAMP
fi
##check if started before
java_pid=`ps --no-heading -C java -f --width 1000 | grep "$JBOSS_BASE_DIR" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
echo "Jboss server already started: pid=$java_pid"
exit;
fi
#########################################copy server home
if [ ! -d "$JBOSS_BASE_DIR" ]; then
rm -f $JBOSS_BASE_DIR
mkdir -p $JBOSS_BASE_DIR
cp -rf $SERVER_HOME/standalone/. $JBOSS_BASE_DIR/.
else
rm -rf $JBOSS_BASE_DIR/tmp
rm -rf $JBOSS_BASE_DIR/data
rm -rf $JBOSS_BASE_DIR/log
fi
deploy
##jmx controle file must be read only else jvm can not startup
chmod 600 $WEB_APP_HOME/conf/jmx/*.properties > /dev/null 2>&1
nohup $SERVER_HOME/bin/standalone.sh
################################################################
copy_jboss_conf(){
cp -rf $WEB_APP_HOME/conf/jboss/standalone.xml $JBOSS_BASE_DIR/configuration/standalone.xml
}
deploy_ear(){
rm -rf $JBOSS_BASE_DIR/deployments/web.ear
rm -rf $JBOSS_BASE_DIR/deployments/web.ear.*
cp -rf $JBOSS_BASE_DIR/web.ear $JBOSS_BASE_DIR/deployments/web.ear
touch $JBOSS_BASE_DIR/deployments/web.ear.dodeploy
}
deploy(){
copy_jboss_conf
deploy_ear
}
\ No newline at end of file
... ...
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-22
################################################################
BASE_BIN_DIR=`dirname $0`
#import home var env
. $BASE_BIN_DIR/env.sh
TIMESTAMP=`date +%Y_%m_%d_%H:%M`
HOST_NAME=`hostname`
LOG_DIR=$WEB_APP_HOME/logs
JBOSS_CHECK_LOG="$LOG_DIR/jboss_stdout.log"
JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default
TOMCAT_BASE_DIR=$WEB_APP_HOME/.tomcat
LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
REMOVE_URL="$GW_URL/service_control/unregister?ip=$LOCAL_IP&context=$SERVER_NAMESPACE"
stop_jboss()
{
JBOSS_JAVA_PID=`get_jboss_pid`
if [ ! -z "$JBOSS_JAVA_PID" ] ; then
echo -e "$HOST_NAME: stopping jboss ...\c"
$JBOSS_HOME/bin/jboss-cli.sh --connect controller=localhost:$NAMING_PORT command=:shutdown > /dev/null 2>&1
LOOPS=0
while [ $LOOPS -lt 30 ]; do
printProcess
kill -s 0 $JBOSS_JAVA_PID > /dev/null 2>&1
if [ $? -eq 1 ]; then
break
fi
let LOOPS=LOOPS+1
done
JBOSS_JAVA_PID=`get_jboss_pid`
if [ ! -z "$JBOSS_JAVA_PID" ] ; then
echo -e "[INFO] kill java process $JBOSS_JAVA_PID .\c"
kill -9 $JBOSS_JAVA_PID > /dev/null 2>&1
fi
success "Oook!"
else
warning "[WARN] $HOST_NAME: jboss not running, who care?"
fi
}
get_jboss_pid(){
STR=`ps -C java -f --width 1000 | grep "$JBOSS_BASE_DIR"|awk '{print $2}'`
echo $STR
}
get_tomcat_pid(){
STR=`ps -C java -f --width 1000 | grep "$TOMCAT_BASE_DIR"|awk '{print $2}'`
echo $STR
}
stop_tomcat(){
TOMCAT_JAVA_PID=`get_tomcat_pid`
if [ ! -z "$TOMCAT_JAVA_PID" ] ; then
success "start to remove service register from zookeeper: $REMOVE_URL"
curl -m 10 -s -o /dev/null "$REMOVE_URL"
sleep 10s
success "success to remove $LOCAL_IP"
#echo -e "$HOST_NAME: stopping tomcat ...\c"
#$SERVER_HOME/bin/catalina.sh stop > /dev/null 2>&1
#LOOPS=0
#while [ $LOOPS -lt 30 ]; do
#printProcess
#kill -s 0 $TOMCAT_JAVA_PID > /dev/null 2>&1
#if [ $? -eq 1 ]; then
#break
#fi
#let LOOPS=LOOPS+1
#done
#TOMCAT_JAVA_PID=`get_tomcat_pid`
#if [ ! -z "$TOMCAT_JAVA_PID" ] ; then
echo -e "[INFO] kill java process $TOMCAT_JAVA_PID .\c"
kill -9 $TOMCAT_JAVA_PID > /dev/null 2>&1
#fi
success "Oook!"
else
warning "[WARN] $HOST_NAME: tomcat not running, who care?"
fi
}
if [ $SERVER_TYPE = "jboss" ]; then
stop_jboss
fi
if [ $SERVER_TYPE = "tomcat" ]; then
stop_tomcat
fi
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-22
################################################################
BASE_BIN_DIR=`dirname $0`
#import home var env
. $BASE_BIN_DIR/env.sh
TIMESTAMP=`date +%Y_%m_%d_%H:%M`
HOST_NAME=`hostname`
LOG_DIR=$WEB_APP_HOME/logs
JBOSS_CHECK_LOG="$LOG_DIR/jboss_stdout.log"
JBOSS_BASE_DIR=$WEB_APP_HOME/.jboss/default
TOMCAT_BASE_DIR=$WEB_APP_HOME/.tomcat
LOCAL_IP=`/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"`
REMOVE_URL="$GW_URL/service_control/unregister?ip=$LOCAL_IP&context=$SERVER_NAMESPACE"
stop_jboss()
{
JBOSS_JAVA_PID=`get_jboss_pid`
if [ ! -z "$JBOSS_JAVA_PID" ] ; then
echo -e "$HOST_NAME: stopping jboss ...\c"
$JBOSS_HOME/bin/jboss-cli.sh --connect controller=localhost:$NAMING_PORT command=:shutdown > /dev/null 2>&1
LOOPS=0
while [ $LOOPS -lt 30 ]; do
printProcess
kill -s 0 $JBOSS_JAVA_PID > /dev/null 2>&1
if [ $? -eq 1 ]; then
break
fi
let LOOPS=LOOPS+1
done
JBOSS_JAVA_PID=`get_jboss_pid`
if [ ! -z "$JBOSS_JAVA_PID" ] ; then
echo -e "[INFO] kill java process $JBOSS_JAVA_PID .\c"
kill -9 $JBOSS_JAVA_PID > /dev/null 2>&1
fi
success "Oook!"
else
warning "[WARN] $HOST_NAME: jboss not running, who care?"
fi
}
get_jboss_pid(){
STR=`ps -C java -f --width 1000 | grep "$JBOSS_BASE_DIR"|awk '{print $2}'`
echo $STR
}
get_tomcat_pid(){
STR=`ps -C java -f --width 1000 | grep "$TOMCAT_BASE_DIR"|awk '{print $2}'`
echo $STR
}
stop_tomcat(){
TOMCAT_JAVA_PID=`get_tomcat_pid`
if [ ! -z "$TOMCAT_JAVA_PID" ] ; then
success "start to remove service register from zookeeper: $REMOVE_URL"
curl -m 10 -s -o /dev/null "$REMOVE_URL"
sleep 10s
success "success to remove $LOCAL_IP"
#echo -e "$HOST_NAME: stopping tomcat ...\c"
#$SERVER_HOME/bin/catalina.sh stop > /dev/null 2>&1
#LOOPS=0
#while [ $LOOPS -lt 30 ]; do
#printProcess
#kill -s 0 $TOMCAT_JAVA_PID > /dev/null 2>&1
#if [ $? -eq 1 ]; then
#break
#fi
#let LOOPS=LOOPS+1
#done
#TOMCAT_JAVA_PID=`get_tomcat_pid`
#if [ ! -z "$TOMCAT_JAVA_PID" ] ; then
echo -e "[INFO] kill java process $TOMCAT_JAVA_PID .\c"
kill -9 $TOMCAT_JAVA_PID > /dev/null 2>&1
#fi
success "Oook!"
else
warning "[WARN] $HOST_NAME: tomcat not running, who care?"
fi
}
if [ $SERVER_TYPE = "jboss" ]; then
stop_jboss
fi
if [ $SERVER_TYPE = "tomcat" ]; then
stop_tomcat
fi
... ...
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-25
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
HOST_NAME=`hostname`
JBOSS_CTL=$BASE_BIN_DIR/jbossctl.sh
TOMCAT_CTL=$BASE_BIN_DIR/tomcatctl.sh
## start jboss
start_jboss(){
echo -e "[INFO] $HOST_NAME: starting jboss ...\c"
chmod +x $BASE_BIN_DIR/jbossctl.sh
$JBOSS_CTL > $JBOSS_STDOUT_LOG 2>&1 &
COUNT=0
printProcess 5
while [ $COUNT -lt 1 ]; do
COUNT=`curl -s $CHECK_SERVER_STARTUP_URL |grep -c "$STARTUP_SUCCESS_MSG"`
printProcess 3
done
success "Oook!"
}
## start tomcat
start_tomcat(){
echo -e "[INFO] $HOST_NAME: starting tomcat ...\c"
chmod +x $BASE_BIN_DIR/tomcatctl.sh
$TOMCAT_CTL &
COUNT=0
printProcess 5
while [ $COUNT -lt 1 ]; do
COUNT=`curl -s $CHECK_SERVER_STARTUP_URL |grep -c "$STARTUP_SUCCESS_MSG"`
printProcess 3
done
success "Oook!"
}
if [ $SERVER_TYPE = "jboss" ]; then
start_jboss
fi
if [ $SERVER_TYPE = "tomcat" ]; then
start_tomcat
fi
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2007-05-25
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
HOST_NAME=`hostname`
JBOSS_CTL=$BASE_BIN_DIR/jbossctl.sh
TOMCAT_CTL=$BASE_BIN_DIR/tomcatctl.sh
## start jboss
start_jboss(){
echo -e "[INFO] $HOST_NAME: starting jboss ...\c"
chmod +x $BASE_BIN_DIR/jbossctl.sh
$JBOSS_CTL > $JBOSS_STDOUT_LOG 2>&1 &
COUNT=0
printProcess 5
while [ $COUNT -lt 1 ]; do
COUNT=`curl -s $CHECK_SERVER_STARTUP_URL |grep -c "$STARTUP_SUCCESS_MSG"`
printProcess 3
done
success "Oook!"
}
## start tomcat
start_tomcat(){
echo -e "[INFO] $HOST_NAME: starting tomcat ...\c"
chmod +x $BASE_BIN_DIR/tomcatctl.sh
$TOMCAT_CTL &
COUNT=0
printProcess 5
while [ $COUNT -lt 1 ]; do
COUNT=`curl -s $CHECK_SERVER_STARTUP_URL |grep -c "$STARTUP_SUCCESS_MSG"`
printProcess 3
done
success "Oook!"
}
if [ $SERVER_TYPE = "jboss" ]; then
start_jboss
fi
if [ $SERVER_TYPE = "tomcat" ]; then
start_tomcat
fi
success "[INFO] $HOSTNAME: startup web server done!"
\ No newline at end of file
... ...
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2015-10-22
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
export CATALINA_HOME=$SERVER_HOME
export CATALINA_BASE=$WEB_APP_HOME/.tomcat
################################################################
##check if started before
check_server(){
java_pid=`ps --no-heading -C java -f --width 1000 | grep "$$CATALINA_BASE" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
echo "[INFO] Tomcat server already started: pid=$java_pid"
exit;
fi
}
copy_server_home(){
if [ -d "$CATALINA_BASE" ]; then
rm -rf $CATALINA_BASE
fi
mkdir -p $CATALINA_BASE/conf
mkdir -p $CATALINA_BASE/webapps
mkdir -p $CATALINA_BASE/logs
mkdir -p $CATALINA_BASE/temp
touch $CATALINA_BASE/logs/catalina.out
}
copy_tomcat_conf(){
cp -rf $SERVER_HOME/conf/. $CATALINA_BASE/conf/.
cp -rf $WEB_APP_HOME/conf/tomcat/server.xml $CATALINA_BASE/conf/server.xml
}
copy_war(){
if [ ! -d $WEB_APP_HOME/$SERVER_NAMESPACE-war ]; then
mkdir -p $WEB_APP_HOME/$SERVER_NAMESPACE-war
cd $WEB_APP_HOME/$SERVER_NAMESPACE-war
mv $WEB_APP_HOME/*.war $WEB_APP_HOME/$SERVER_NAMESPACE-war/$SERVER_NAMESPACE.war
$JAVA_HOME/bin/jar xf $SERVER_NAMESPACE.war
rm -rf $WEB_APP_HOME/$SERVER_NAMESPACE-war/$SERVER_NAMESPACE.war
fi
cp -r $WEB_APP_HOME/$SERVER_NAMESPACE-war $CATALINA_BASE/webapps/$SERVER_NAMESPACE
}
deploy(){
check_server
copy_server_home
copy_tomcat_conf
copy_war
}
###############################################################
deploy
#!/bin/bash
################################################################
#@Authro Lijian
#@Date 2015-10-22
################################################################
BASE_BIN_DIR=`dirname $0`
. $BASE_BIN_DIR/env.sh
export CATALINA_HOME=$SERVER_HOME
export CATALINA_BASE=$WEB_APP_HOME/.tomcat
################################################################
##check if started before
check_server(){
java_pid=`ps --no-heading -C java -f --width 1000 | grep "$$CATALINA_BASE" |awk '{print $2}'`
if [ ! -z "$java_pid" ]; then
echo "[INFO] Tomcat server already started: pid=$java_pid"
exit;
fi
}
copy_server_home(){
if [ -d "$CATALINA_BASE" ]; then
rm -rf $CATALINA_BASE
fi
mkdir -p $CATALINA_BASE/conf
mkdir -p $CATALINA_BASE/webapps
mkdir -p $CATALINA_BASE/logs
mkdir -p $CATALINA_BASE/temp
touch $CATALINA_BASE/logs/catalina.out
}
copy_tomcat_conf(){
cp -rf $SERVER_HOME/conf/. $CATALINA_BASE/conf/.
cp -rf $WEB_APP_HOME/conf/tomcat/server.xml $CATALINA_BASE/conf/server.xml
}
copy_war(){
if [ ! -d $WEB_APP_HOME/$SERVER_NAMESPACE-war ]; then
mkdir -p $WEB_APP_HOME/$SERVER_NAMESPACE-war
cd $WEB_APP_HOME/$SERVER_NAMESPACE-war
mv $WEB_APP_HOME/*.war $WEB_APP_HOME/$SERVER_NAMESPACE-war/$SERVER_NAMESPACE.war
$JAVA_HOME/bin/jar xf $SERVER_NAMESPACE.war
rm -rf $WEB_APP_HOME/$SERVER_NAMESPACE-war/$SERVER_NAMESPACE.war
fi
cp -r $WEB_APP_HOME/$SERVER_NAMESPACE-war $CATALINA_BASE/webapps/$SERVER_NAMESPACE
}
deploy(){
check_server
copy_server_home
copy_tomcat_conf
copy_war
}
###############################################################
deploy
$SERVER_HOME/bin/catalina.sh start > /dev/null
\ No newline at end of file
... ...