一体化启动脚本

6886人浏览 / 0人评论
#!/bin/sh
#判断进程是否存在,如果不存在就启动它
APP_JAR="/release/es1-1.0-SNAPSHOT.jar"
MEM="2g"
IP="192.168.31.243"
PORT="18761"
ENV="test"

PIDS=`ps -ef |grep "$APP_JAR" |grep -v grep | awk '{print $2}'`
if [ "$PIDS" != "" ]; then
kill -9 $PIDS 
echo "$APP_JAR 已被杀死"
else
echo '程序未运行'
fi

JAVA_MEM_OPTS=" -server -Xms"${MEM}" -Xmx"${MEM}" -XX:+UseParallelGC "
echo ${JAVA_MEM_OPTS}
java   $JAVA_MEM_OPTS   -jar $APP_JAR $1 --spring.profiles.active=$ENV &
echo "程序启动中。。。"

for(( i=1;i<=100;i=i+1))
do
if [ `curl -I -m 10 -o /dev/null -s -w %{http_code} "$IP":"$PORT"/info` = 200 ]; then
	echo "项目"${APP_JAR}"启动成功"
    exit 0
fi
echo "==================访问http://"${IP}":"${PORT}"第$i次======================================="
sleep 1
done
echo "======================启动失败============================================="
exit 1

 

全部评论