stop.sh
803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# 切换到脚本所在目录
cd "$(dirname "$0")"
SYNC_PID="sync.pid"
API_PID="api.pid"
echo "=== 门店管理服务停止脚本 ==="
stop_process() {
local pid_file=$1
local name=$2
if [ ! -f "$pid_file" ]; then
echo "跳过: $name (未发现 PID 文件)"
return
fi
PID=$(cat "$pid_file")
if ps -p $PID > /dev/null 2>&1; then
echo "正在停止 $name (PID: $PID)..."
kill $PID
sleep 1
if ps -p $PID > /dev/null 2>&1; then
kill -9 $PID
fi
echo "$name 已停止。"
else
echo "警告: $name 进程已不存在。"
fi
rm "$pid_file"
}
# 停止两个服务
stop_process "$SYNC_PID" "同步服务"
stop_process "$API_PID" "API 服务"
echo "清理完成。"