docs(pgdb): compose 开机竞态故障修复 + 自愈 unit (W1N-260)
- 根因:开机时 docker 恢复容器绑定 192.168.55.15:5432/8081 失败(EADDRNOTAVAIL,IP 尚未可绑)→ timescaledb/pgweb 启动失败且不重试,停摆 3h15m;pg-backup 开机备份失败 → unhealthy - 处置:docker compose up -d --force-recreate(三容器回 database_default、端口发布、备份恢复、pgweb 恢复);用户重启 HA Core 后写入管道恢复 - 防复发:新增开机自愈 systemd oneshot pgdb-compose.service(enabled),源码 compose/pgdb/pgdb-compose.service
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
[Unit]
|
||||
Description=Reconcile pgdb compose stack (timescaledb + pgweb + pg-backup) at boot
|
||||
Documentation=file:///opt/database/docker-compose.yml
|
||||
After=network-online.target docker.service
|
||||
Wants=network-online.target
|
||||
Requires=docker.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/opt/database
|
||||
# Idempotent boot-time reconcile. docker's own restore can fail to bind the
|
||||
# published ports (192.168.55.15:5432/8081) when the VM IP is not yet usable
|
||||
# right after boot (EADDRNOTAVAIL, observed 2026-08-30): timescaledb/pgweb
|
||||
# then stay stopped until a manual `docker compose up`. This unit retries
|
||||
# `docker compose up -d` (a no-op when the stack is healthy) until the port
|
||||
# listens, and force-recreates as a last resort to recover a network-detached
|
||||
# container. Data lives on bind mounts (/srv/pgdata, /opt/database/backups),
|
||||
# so recreation is safe.
|
||||
ExecStart=/bin/bash -c 'for i in $(seq 1 12); do docker compose up -d --remove-orphans; sleep 2; if ss -tln | grep -q "192.168.55.15:5432"; then exit 0; fi; sleep 3; done; echo "pgdb-compose: retries exhausted, force-recreating"; docker compose up -d --force-recreate; sleep 10; ss -tln | grep -q "192.168.55.15:5432"'
|
||||
TimeoutStartSec=180
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user