25 lines
1.2 KiB
Desktop File
25 lines
1.2 KiB
Desktop File
[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
|