Files
spdm-backend/flowable/src/main/resources/bin/65/stop.sh

41 lines
815 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Spring Boot 项目停止脚本
JAR_NAME="flowable-0.0.1-SNAPSHOT.jar"
# 函数定义
get_running_pid() {
ps -ef | grep "${JAR_NAME}" | grep -v "grep" | awk '{print $2}'
}
# 停止服务
PID=$(get_running_pid)
if [ -z "${PID}" ]; then
echo "项目未在运行中,无需停止"
exit 0
fi
echo "正在停止项目... PID: ${PID}"
kill -15 "${PID}"
WAIT=0
while [ ${WAIT} -lt 10 ]; do
if [ -z "$(get_running_pid)" ]; then
echo "项目已优雅停止"
exit 0
fi
sleep 1
WAIT=$((WAIT + 1))
done
echo "优雅停止超时,强制终止进程... PID: ${PID}"
kill -9 "${PID}"
sleep 2
if [ -z "$(get_running_pid)" ]; then
echo "项目已强制停止"
else
echo "ERROR: 进程终止失败请手动检查ps -ef | grep ${JAR_NAME}"
exit 1
fi