shutdown.sh
949 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
# 获取脚本所在目录
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR" || exit
source "${SCRIPT_DIR}/config.sh"
# 记录日志函数
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1"
}
log "Stopping health check service..."
sudo systemctl stop "health-check-${SERVICE_NAME}"
sudo systemctl disable "health-check-${SERVICE_NAME}"
log "Stopping $SERVICE_NAME service..."
sudo systemctl stop "$SERVICE_NAME"
sudo systemctl disable "$SERVICE_NAME"
# 检查服务停止状态
if systemctl is-active --quiet "$SERVICE_NAME"; then
log "Warning: Service $SERVICE_NAME may still be running"
exit 1
else
log "Service $SERVICE_NAME stopped successfully"
fi
# 检查健康检查服务停止状态
if systemctl is-active --quiet "health-check-${SERVICE_NAME}"; then
log "Warning: Health check service may still be running"
else
log "Health check service stopped successfully"
fi
exit 0