- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/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}"
|
|
COMPOSE_FILE="${2:?Compose file path required}"
|
|
ENV_FILE="${3:-}"
|
|
|
|
if docker compose version >/dev/null 2>&1; then
|
|
DC_CMD=(docker compose)
|
|
elif command -v docker-compose >/dev/null 2>&1; then
|
|
DC_CMD=(docker-compose)
|
|
else
|
|
echo "Missing docker compose command. Install docker compose plugin or docker-compose."
|
|
exit 1
|
|
fi
|
|
|
|
declare -a compose_args=(-f "${COMPOSE_FILE}")
|
|
if [[ -n "${ENV_FILE}" && -f "${ENV_FILE}" ]]; then
|
|
compose_args+=(--env-file "${ENV_FILE}")
|
|
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
|
|
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}); missing: ${missing_services[*]}"
|
|
sleep "${sleep_seconds}"
|
|
done
|
|
|
|
echo "Healthcheck failed for ${ENV_NAME} environment."
|
|
"${DC_CMD[@]}" "${compose_args[@]}" ps
|
|
exit 1
|