Files
wrong-notebook/packaging/synology/scripts/start-stop-status
margrop 3e6ccb30c4 fix: 修复群晖套件健康状态误判并加固 NAS 证书目录与日志轮转
- start-stop-status 改用 curl -sf 并校验 status=ok,404/500/503 不再误报运行中
- 证书目录支持 CERT_DIR,非 root 且 /app/certs 不可写时回退到 CONFIG_DIR/certs
- 群晖 compose 补充 WN_PLATFORM 与日志轮转,CI 覆盖全部 NAS 脚本语法检查
- 新增 tests/publication/test_nas_packaging.py 验证健康状态与打包配置
2026-12-04 20:25:17 +08:00

49 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
# 群晖套件服务控制。脚本以套件用户运行,不能调用 docker:
# 容器由 conf/resource 的 docker-project 资源随套件启停,这里只按服务端口报告状态。
set -eu
WN_HOST_PORT=39300
# 仅健康检查返回 200 且 status=ok 时视为运行中;数据库迁移未就绪时返回 503,继续等待
responding() {
body="$(curl -sf --max-time 5 "http://127.0.0.1:${WN_HOST_PORT}/api/health" 2>/dev/null)" || return 1
case "$body" in
*'"status":"ok"'*) return 0 ;;
*) return 1 ;;
esac
}
wait_responding() {
i=0
while [ "${i}" -lt 90 ]; do
if responding; then
return 0
fi
i=$((i + 1))
sleep 2
done
return 1
}
case "${1:-status}" in
start)
if ! wait_responding; then
echo "错题本容器未在预期时间内响应,请在 Container Manager 的「项目」中查看 wrong-notebook 的日志。"
exit 1
fi
;;
stop | prestart | prestop) ;;
status)
if responding; then
exit 0
fi
exit 3
;;
*)
echo "Usage: $0 {start|stop|status}" >&2
exit 1
;;
esac
exit 0