fix(deploy): sync deploy/systemd/ units from webhook-deploy.sh (BIT-28183)
Tests / bridge tests (pull_request) Successful in 1m22s
Tests / bridge tests (push) Successful in 1m54s
Tests / writer-pipeline tests (pull_request) Successful in 1m27s
Tests / writer-pipeline tests (push) Successful in 1m56s
Tests / frontend lib tests (push) Successful in 1m56s
Tests / frontend lib tests (pull_request) Successful in 48s

The cron-driven webhook-deploy.sh never refreshed /etc/systemd/system,
so new/changed units in deploy/systemd/ silently rotted in git after
the one-shot deploy.sh bootstrap (root cause of the BIT-28132 gap).
Add a step that copies deploy/systemd/*.service and *.timer to
/etc/systemd/system + daemon-reload whenever deploy/systemd/ changes
in the diff; new units still need one manual systemctl enable --now.

Also record the BIT-28183 decision to keep the 5-minute cron poll as
the permanent deploy path on CT222 and leave news-deploy-hook.service
unenabled, in docs/deployment.md.

Paperclip-Agent: Tiago Neves (urlKey tiago-neves; id 5d084b36-f38f-42a5-a92a-520005afda4f)
Paperclip-Issue: BIT-28183
Paperclip-Run: 267defb1-b2d1-4a95-a8c0-4dd1c777834e
This commit is contained in:
tiago-neves committed 2026-08-05 02:52:17 +01:00
1 parent a7a04881cc
commit 9e41743c53
2 files changed
+16 -1

No files matched your search

+13
View File
@@ -81,6 +81,19 @@ if git diff --name-only "$LOCAL" "$REMOTE" | grep -q "^deploy/nginx/"; then
log "Nginx reloaded."
fi
# Sync systemd units if deploy/systemd/ changed (BIT-28183 — deploy.sh installs these
# once at bootstrap; webhook-deploy.sh never refreshed them, so new/changed units in
# git silently never reached /etc/systemd/system on subsequent deploys).
if git diff --name-only "$LOCAL" "$REMOTE" | grep -q "^deploy/systemd/"; then
log "Systemd units changed — syncing to /etc/systemd/system..."
for src in "$APP_DIR"/deploy/systemd/*.service "$APP_DIR"/deploy/systemd/*.timer; do
[ -f "$src" ] || continue
cp "$src" "/etc/systemd/system/$(basename "$src")"
done
systemctl daemon-reload
log "Systemd units synced. New units are not auto-enabled/started — enable per docs/deployment.md."
fi
# Domain JSON is cached in the bridge process — restart when config changes
if git diff --name-only "$LOCAL" "$REMOTE" | grep -q "^config/"; then
log "Domain config changed — restarting bridge + frontend..."
+3 -1
View File
@@ -241,7 +241,7 @@ pm2 startup
After the first manual bootstrap, pushes to `main` can trigger a pull + selective rebuild on the container.
1. **Script** — `deploy/scripts/webhook-deploy.sh` compares `HEAD` to `origin/main`, runs `git reset --hard`, rebuilds bridge/frontend when those trees change, reloads nginx when `deploy/nginx/` changes, restarts bridge + frontend when `config/` changes (domain JSON is cached in the bridge process), and runs `docker compose` when `wordpress/` changes.
1. **Script** — `deploy/scripts/webhook-deploy.sh` compares `HEAD` to `origin/main`, runs `git reset --hard`, rebuilds bridge/frontend when those trees change, reloads nginx when `deploy/nginx/` changes, syncs `deploy/systemd/*.service` and `*.timer` into `/etc/systemd/system/` + `daemon-reload` when `deploy/systemd/` changes (BIT-28183 — units are copied but not auto-enabled/started, so a brand-new unit still needs one manual `systemctl enable --now`; a change to a unit already enabled just needs `systemctl restart <unit>`), restarts bridge + frontend when `config/` changes (domain JSON is cached in the bridge process), and runs `docker compose` when `wordpress/` changes.
2. **Hook server** — `deploy/scripts/deploy-hook-server.mjs` listens on loopback (default `127.0.0.1:9090`), path `POST /hook`, and accepts `Authorization: Bearer <token>` or `X-Deploy-Token` matching `DEPLOY_HOOK_TOKEN`. It returns `202` and runs the script in the background. Systemd unit: `deploy/systemd/news-deploy-hook.service`; env template: `deploy/systemd/deploy-hook.env.example` → `/etc/news-platform/deploy-hook.env`.
@@ -249,6 +249,8 @@ After the first manual bootstrap, pushes to `main` can trigger a pull + selectiv
4. **Alternative** — Gitea **Actions** can `curl -fsS -X POST -H "Authorization: Bearer $TOKEN" http://.../hook` from a runner that has network access to the CT.
**Decision (BIT-28183, 2026-08-05): the 5-minute cron poll is the accepted permanent design on CT222.** `news-deploy-hook.service` is *not enabled* there — deploys go through `webhook-deploy.sh` via the root crontab only. (The step-1 systemd sync copies its unit file to `/etc/systemd/system/` like any other `deploy/systemd/*.service`, since a stale/missing copy on disk is exactly the BIT-28183 bug; a unit that's merely present but never enabled stays inactive and harmless.) Rationale for not enabling it: the push-hook adds a second listening service (`:9090`) plus a bearer-token secret to manage, for a latency win (≤5 min saved) that doesn't matter for this platform's publish cadence. The hook server code and unit stay in the repo as a documented, ready-to-enable option (steps 2–4 above) if a future workload needs faster propagation — enabling it then is: fill `deploy-hook.env.example` → `/etc/news-platform/deploy-hook.env`, `systemctl enable --now news-deploy-hook`, then wire the Gitea webhook (step 3). Until that decision changes, don't add `news-deploy-hook.service` to `deploy.sh`'s curated install/enable loop, and don't `systemctl enable` it manually on CT222.
---
## Writer Pipeline — andebol.net (systemd timer)