首页 > 编程语言 > 详细

Java web 应用自启动 shell脚本自动重启

时间:2019-07-04 19:08:42      阅读:121      评论:0      收藏:0      [点我收藏+]

之前公司的内部管理系统jenkins自动构建代码有时候会失效,导致服务停掉。

于是乎就搞了一个自动启动脚本。

oa.jar就是监测的服务

startup.sh 的内容是运行jar包的命令

java -jar oa.jar --spring.profiles.active=xxx &

#!/bin/bash

while :

do

  echo "Current DIR is " $PWD

  stillRunning=$(ps -ef |grep "$PWD/oa.jar" |grep -v "grep")

  if [ "$stillRunning" ] ; then

    echo "TWS service was already started by another way"

    echo "Kill it and then startup by this shell, other wise this shell will loop out this message annoyingly"

    kill -9 $pidof $PWD/oa.jar

  else

    echo "TWS service was not started"

    echo "Starting service ..."

    $PWD/startup.sh

    echo "TWS service was exited!"

  fi

  sleep 30

done

Java web 应用自启动 shell脚本自动重启

原文:https://www.cnblogs.com/wendao1996/p/11134217.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!