#!/bin/bash
APP_NAME=/soft/hse-protal-web-0.0.1-SNAPSHOT.jar
APP_PORT=8080
#使用说明,用来提示输入参数
usage() {
echo "Usage: sh start-hse-web-service.sh [start|stop|restart|status|start8080|stop8080|restart8080|status8080]"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'`
#如果不存在返回1,存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#检查程序是否在运行
is_exist8080(){
pid=`lsof -i:$APP_PORT|grep -v grep|awk '{print $2}'`
#如果不存在返回1,存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq 0 ]; then
echo "${APP_NAME} is already running. pid=${pid}"
else
nohup java -jar ${APP_NAME} --spring.profiles.active=prod >/dev/null 2>&1 &
fi
}
#停止方法
stop(){
is_exist
if [ $? -eq "0" ]; then
kill -9 $pid
else
echo
shell脚本-启动 停止 重启服务,根据端口或jar
最新推荐文章于 2024-10-01 08:53:25 发布