refactor(scheduler): 排程迁移出web进程,迁入scheduler worker

This commit is contained in:
sophie committed 2026-07-30 19:52:41 +08:00
1 parent 970ee06537
commit 74745a9d10
21 files changed
+652 -223

No files matched your search

+15 -3
View File
@@ -1,4 +1,9 @@
#!/usr/bin/env bash
#
# scripts/healthcheck.sh
# 用途:部署后确认 Web 与后台 Worker 服务均处于 running。
# 依赖:docker compose、docker-compose.yml、目标环境 env 文件。
# 逻辑:逐个检查核心服务,避免仅按容器数量判断而漏掉 schedule/KB worker 启动失败。
set -euo pipefail
ENV_NAME="${1:-default}"
@@ -21,15 +26,22 @@ fi
max_attempts=20
sleep_seconds=3
required_services=(hxops-backend hxops-frontend hxops-kb-worker hxops-schedule-worker)
for ((i=1; i<=max_attempts; i++)); do
status=$("${DC_CMD[@]}" "${compose_args[@]}" ps --status running --services | wc -l)
if [[ "${status}" -ge 2 ]]; then
mapfile -t running_services < <("${DC_CMD[@]}" "${compose_args[@]}" ps --status running --services)
missing_services=()
for service in "${required_services[@]}"; do
if ! printf '%s\n' "${running_services[@]}" | grep -qx "${service}"; then
missing_services+=("${service}")
fi
done
if [[ ${#missing_services[@]} -eq 0 ]]; then
echo "Healthcheck passed for ${ENV_NAME} environment."
exit 0
fi
echo "Healthcheck waiting (${i}/${max_attempts})..."
echo "Healthcheck waiting (${i}/${max_attempts}); missing: ${missing_services[*]}"
sleep "${sleep_seconds}"
done