shutdown.sh 949 Bytes
#!/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