springboot项目简单启动脚本

#!/bin/bash

function log_info () { 
DATE=`date "+%Y-%m-%d %H:%M:%S"`
USER=$(whoami)
echo "${DATE} ${USER} execute $0 [INFO] $@"
}

function log_error () 
{ 
DATE=`date "+%Y-%m-%d %H:%M:%S"`
USER=$(whoami)
echo "${DATE} ${USER} execute $0 [ERROR] $@"
}

function fn_log () 
{ 
if [ $? -eq 0 ]; then 
	log_info "$@ sucessed!"
else 
	log_error "$@ failed!"
	exit 
fi 
}

# cd 51token
# git pull
# cd token-api
# get pid
# kill pid
# mvn clean package
# cd target
# nohup java -jar ... >/dev/null &

APP="token-api-0.0.1-SNAPSHOT.jar"

cd ~/51token

git pull
fn_log "git pull"

sleep 3

cd token-api

PID=`ps -C java -f | grep $APP | awk '{print $2}'`
fn_log "ps -C java -f | grep $APP | awk '{print $2}"

if [ -n "$PID" ]; then
	kill 9 $PID
	fn_log "kill 9 $PID"
fi

sleep 2

mvn clean package
fn_log "mvn clean package"

sleep 5

cd target
if [ -f "$APP" ]; then
	nohup java -jar $APP >/dev/null &
	fn_log "nohup java -jar $APP >/dev/null &"
else
	echo "package not exist"
	exit
fi

ss -tlnp

COUNT=15
while [ $COUNT -gt 0 ]; do
        echo "wait"
        COUNT=`expr $COUNT "-" 1`
        sleep 1
done

ss -tlnp

  

转载于:https://www.cnblogs.com/tq1226112215/p/9395810.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值