美文网首页
服务启动脚本

服务启动脚本

作者: 抄无止境 | 来源:发表于2022-03-07 14:52 被阅读0次
#!/bin/bash
echo "xxxxx测试环境》》》》》》》"
echo ""
echo "0.xxxx【xxxxx】服务"
echo "100.关闭所有测试进程"


read -p  "输入编号:" sNO

case "$sNO" in

0)                                                                                                     
bash /usr/bin/xxxx/xxx-xxx.sh                                                                  
;;

100)
ps -ef|grep '/data/java/bin'|grep -v grep|awk '{print $2}'|xargs sudo kill -9
;;

*)
echo "无此应用"
;;

esac

#!/bin/sh
export LANG="zh_CN.UTF-8"


PIDS=`ps -ef|grep "clone"|grep -v grep`
if [ "$PIDS" != "" ]; then
echo "有人正在重启中,你的被取消!!!!"
exit
else
echo "success"
fi


PIDS=`ps -ef|grep "Launcher"|grep -v grep`
if [ "$PIDS" != "" ]; then
echo "有人正在重启中,你的被取消!!!!"
exit
else
echo "success"
fi


prog_name=xxxxxx-api-1.0.jar

if [ -d /data/java/xxxxxx-java ]
then
        rm -rf /data/java/xxxxxx-java
        echo "存在目录 删除当前目录"
else
        echo "不存在目录 无需删除"
fi

cd /data/java
git clone -b test root@xxx.xxx.xxx.xxx:xxxxxx/xxxxxx-java.git
cd /data/java/xxxxxx-java
mvn initialize
mvn -DskipTests=true clean package -pl xxxxxx-api -am
cp -r /data/java/xxxxxx-java/xxxxxx-api/target/xxxxxx-api-1.0.jar /data/www/test/web_api
#rm -rf /data/java/xxxxxx-java
cd /data/www/test/web_api

prog_id=`ps -ef | grep $prog_name | grep -v grep | awk '{print $2}'`

if [ x$prog_id = x ] ; then
    echo "$prog_name is stopped"
else
    kill -9 $prog_id
    echo "stop $prog_name"
fi

for i in {1..10};do
    prog_id=`ps -ef | grep $prog_name | grep -v grep | awk '{print $2}'`
    if [ x"$prog_id" = x ] ; then
        break
    fi
done

sleep 5

if [ x$prog_id = x ] ; then
    echo "start $prog_name"
    nohup java -Dfile.encoding=utf-8 -Xmx256m -jar -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=18081 /data/www/test/web_api/quanjiyang-api-1.0.jar --spring.profiles.active=test >> /data/logs/null 2>&1 &
else
    echo "$prog_name is started"
fi
```:

相关文章

网友评论

      本文标题:服务启动脚本

      本文链接:https://www.haomeiwen.com/subject/xahnrrtx.html