shell之startup #!/bin/sh
#
#
#
#
PROJECT=$1
APPWORK_DIR=~/apps/$PROJECT
LOGPATH=~/logs/$1
LOGFILE=~/logs/$PROJECT/${PROJECT}.log
STARTUPLOG=~/logs/$1/startup.log
JAVA_OPTIS=" -Xms40m -Xmx512m -Xss256k -Dspring.profiles.active=test "
JAR=$APPWORK_DIR/$1.jar
#JAVA_OPTIS=" -Xms1024m -Xmx1024m -Xss256k -Dspring.profiles.active=test "
DEPLOY_CONFIG=$APPWORK_f
PIDFILE=$APPWORK_DIR/$1.pid
if [ ! -f $JAR ];then
echo "$JAR 不存在,正在搜索WAR包..."
JAR=$APPWORK_DIR/$PROJECT.war
fi
if [ ! -f $JAR ]; then
echo "$JAR 不存在,请确认是否编译成功,并成功布署."shell代码
exit 0;
fi
if [ -f $DEPLOY_CONFIG ]; then
echo "读取应⽤⾃定义布署配置⽂件- $DEPLOY_CONFIG "
source $DEPLOY_CONFIG
fi
#初始化⽇志⽬录
if [ ! -d $LOGPATH ]; then
echo "正在创建⽇志⽬录${LOGPATH}"
mkdir -p $LOGPATH
fi
echo ">>>>>>>#"
echo "JAVA_HOME=$JAVA_HOME"
echo "JAVA_OPTIS=$JAVA_OPTIS"
echo "ADD_VM_ARGS=$ADD_VM_ARGS"
echo "STARTUP_ARGS=$STARTUP_ARGS"
echo "PIDFILE=$PIDFILE"
echo "ApplicationFile=$JAR"
echo "SPRING_CONFIG_URI=$SPRING_CONFIG_URI"
echo "param1=$1"
echo ">>>>>>>#"
echo ""
echo "-------------------------------------------------------------------------"
echo "HANGUDA Startup Script for Linux"
echo "-------------------------------------------------------------------------"
echo "正在执⾏ java -jar $JAVA_OPTIS $ADD_VM_ARGS $JAR $STARTUP_ARGS >$STARTUPLOG &" nohup java -jar $JAVA_OPTIS $ADD_VM_ARGS $JAR $STARTUP_ARGS >$STARTUPLOG & RESULT=$?
PID=$!
if [ $RESULT = 0 ]; then
#JAVA_OPTIS=" -Xms1024m -Xmx1024m -Xss256k -Dspring.profiles.active=test "
DEPLOY_CONFIG=$APPWORK_f
PIDFILE=$APPWORK_DIR/$1.pid
if [ ! -f $JAR ];then
echo "$JAR 不存在,正在搜索WAR包..."
JAR=$APPWORK_DIR/$PROJECT.war
fi
if [ ! -f $JAR ]; then
echo "$JAR 不存在,请确认是否编译成功,并成功布署."
exit 0;
fi
if [ -f $DEPLOY_CONFIG ]; then
echo "读取应⽤⾃定义布署配置⽂件- $DEPLOY_CONFIG "
source $DEPLOY_CONFIG
fi
#初始化⽇志⽬录
if [ ! -d $LOGPATH ]; then
echo "正在创建⽇志⽬录${LOGPATH}"
mkdir -p $LOGPATH
fi
echo ">>>>>>>#"
echo "JAVA_HOME=$JAVA_HOME"
echo "JAVA_OPTIS=$JAVA_OPTIS"
echo "ADD_VM_ARGS=$ADD_VM_ARGS"
echo "STARTUP_ARGS=$STARTUP_ARGS"
echo "PIDFILE=$PIDFILE"
echo "ApplicationFile=$JAR"
echo "SPRING_CONFIG_URI=$SPRING_CONFIG_URI"
echo "param1=$1"
echo ">>>>>>>#"
echo ""
echo "-------------------------------------------------------------------------"
echo "HANGUDA Startup Script for Linux"
echo "-------------------------------------------------------------------------"
echo "正在执⾏ java -jar $JAVA_OPTIS $ADD_VM_ARGS $JAR $STARTUP_ARGS >$STARTUPLOG &" nohup java -jar $JAVA_OPTIS $ADD_VM_ARGS $JAR $STARTUP_ARGS >$STARTUPLOG & RESULT=$?
PID=$!
if [ $RESULT = 0 ]; then
echo  "start $JAR successed PID=$PID ."
echo  $PID >$PIDFILE
sleep 3
tail -300 $STARTUPLOG
tail -300f $LOGFILE
else
echo ""
fi
exit 0
View Code

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论