worklog/scripts/stop.sh
zhangjf 814265d88e refactor: 重构项目目录结构和打包配置
1. 配置文件不包含 *example 文件
2. scripts 目录迁移到项目根目录
3. env.properties 迁移到 scripts 目录
4. MAIN_CLASS 参数迁移到 service.properties
5. assembly.xml 更新脚本和配置文件路径
6. 添加前端打包脚本:
   - build-web.sh: 管理后台打包
   - build-mobile.sh: 移动端H5打包
   - build-all.sh: 全量打包
7. 更新 .gitignore 忽略配置
2026-02-24 18:28:04 +08:00

61 lines
1.4 KiB
Bash
Executable File
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
# ====================================================
# 工作日志服务平台 - 应用停止脚本
# ====================================================
# 应用配置
APP_NAME="worklog-api"
APP_HOME="/opt/worklog/${APP_NAME}"
PID_FILE="${APP_HOME}/${APP_NAME}.pid"
# 检查 PID 文件是否存在
if [ ! -f "${PID_FILE}" ]; then
echo "应用未运行(找不到 PID 文件)"
exit 0
fi
# 读取 PID
PID=$(cat "${PID_FILE}")
# 检查进程是否存在
if ! ps -p ${PID} > /dev/null 2>&1; then
echo "应用未运行(进程不存在)"
rm -f "${PID_FILE}"
exit 0
fi
echo "========================================="
echo "停止应用: ${APP_NAME}"
echo "PID: ${PID}"
echo "========================================="
# 优雅停止(发送 SIGTERM
echo "发送停止信号..."
kill ${PID}
# 等待进程结束(最多等待 30 秒)
TIMEOUT=30
COUNT=0
while ps -p ${PID} > /dev/null 2>&1; do
if [ ${COUNT} -ge ${TIMEOUT} ]; then
echo "WARNING: 应用未在 ${TIMEOUT} 秒内停止,强制终止..."
kill -9 ${PID}
sleep 2
break
fi
echo "等待应用停止... (${COUNT}/${TIMEOUT})"
sleep 1
COUNT=$((COUNT + 1))
done
# 确认进程已停止
if ps -p ${PID} > /dev/null 2>&1; then
echo "ERROR: 无法停止应用"
exit 1
else
echo "应用已停止"
rm -f "${PID_FILE}"
exit 0
fi