标签:dsp cti == serve null 执行 启动失败 定义变量 gdi
[root@iZbp1cu6joizb2nffd7jwkZ server]# cat start.sh
#!/bin/sh
## java 选项
#export JAVA_HOME=/usr/local/java/jdk1.8.0_101
#export JRE_HOME=$JAVA_HOME/jre
ERR_HELP="错误:缺少参数,启动方式: start.sh [服务名]"
# 判断是否有第一个参数指定服务名
if [ "$1" == "" ]; then
echo $ERR_HELP
exit 0
fi
# 定义变量
SERVICE_NAME=$1
if [ $SERVICE_NAME = "zhwy" ]; then
SERVICE_DIR=api
else
SERVICE_DIR=${SERVICE_NAME:0:3}
fi
SERVICE_DIR=/data/server/$SERVICE_DIR
JAR_NAME=$SERVICE_NAME.jar
# 进入目录
cd $SERVICE_DIR
echo "====== 开始启动 $SERVICE_NAME ======"
# 执行停止命令
pid=`ps -ef | grep $SERVICE_NAME | grep java | grep -v "grep" | awk ‘{print $2}‘`
if [ "$pid" = "" ]; then
echo "====== 未发现运行中的服务,跳过停止服务 ======"
else
echo "====== 发现 $SERVICE_NAME 服务运行中 pid: $pid ======"
echo "====== 开始杀进程: $pid ======"
kill -9 $pid
fi
# 执行启动命令
echo "====== 执行启动 ======"
if [ "$1" == "api" ]; then
nohup /usr/local/jdk1.8.0_171/bin/java -Xms256m -Xmx512m -jar -Dspring.profiles.active=cn -Dapp.name=${SERVICE_NAME} -Ddingding.token=99bec505aef6b65063d3c9d8f597c32fbff77830757156df816fee01dea82837 $JAR_NAME >/dev/null 2>&1 &
else
nohup /usr/local/jdk1.8.0_171/bin/java -Xms256m -Xmx512m -jar -Dspring.profiles.active=cn -Dapp.name=${SERVICE_NAME} -Ddingding.token=99bec505aef6b65063d3c9d8f597c32fbff77830757156df816fee01dea82837 $JAR_NAME >/dev/null 2>&1 &
fi
# 5s检查服务
echo "====== 5秒后检查服务启动状态 ======"
sleep 1
echo "====== 4秒后检查服务启动状态 ======"
sleep 1
echo "====== 3秒后检查服务启动状态 ======"
sleep 1
echo "====== 2秒后检查服务启动状态 ======"
sleep 1
echo "====== 1秒后检查服务启动状态 ======"
sleep 1
# 检查服务状态
pid=`ps -ef | grep $SERVICE_NAME | grep java | grep -v "grep" | awk ‘{print $2}‘`
if [ "$pid" = "" ]; then
sh /data/server/notify-dingding.sh 启动 $SERVICE_NAME 失败
echo "====== 啊哦,服务启动失败 ====="
else
sh /data/server/notify-dingding.sh 启动 $SERVICE_NAME 成功
echo "======恭喜,启动成功====="
fi
# 退出命令
exit 0
标签:dsp cti == serve null 执行 启动失败 定义变量 gdi
原文地址:https://www.cnblogs.com/senjiang/p/9765162.html