diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..ed7eacf --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,12 @@ +# Tier 2 baseline CODEOWNERS for BitReport repos +# Replace/add owners as needed per repository domain. + +# CI and forge metadata +/.gitea/ @tiago-neves @david-santos +/.gitea/workflows/ @tiago-neves @david-santos + +# Documentation +/docs/ @david-santos @planner + +# Catch-all +* @david-santos diff --git a/deploy/scripts/cf-cache-rules-apply.sh b/deploy/scripts/cf-cache-rules-apply.sh new file mode 100755 index 0000000..8535199 --- /dev/null +++ b/deploy/scripts/cf-cache-rules-apply.sh @@ -0,0 +1,125 @@ +#!/usr/bin/env bash +# Apply Cloudflare HTML Cache Rules for news-platform zones (BIT-21912 / BIT-21847) +# +# Usage: CF_API_TOKEN= bash deploy/scripts/cf-cache-rules-apply.sh +# +# Requires: CF_API_TOKEN with Cache Rules write permission for andebol.net +# and newsproject.bitreport.pt zones. +set -euo pipefail + +: "${CF_API_TOKEN:?CF_API_TOKEN must be set (Cloudflare API token with Cache Rules write)}" + +CF_API="https://api.cloudflare.com/client/v4" + +get_zone_id() { + local name=$1 + local result + result=$(curl -fsS "$CF_API/zones?name=$name" \ + -H "Authorization: Bearer $CF_API_TOKEN") + echo "$result" | python3 -c " +import sys, json +d = json.load(sys.stdin) +if not d.get('result'): + raise SystemExit(f'Zone not found or token lacks read permission for: ${name}') +print(d['result'][0]['id']) +" +} + +upsert_cache_rule() { + local zone_id=$1 + local expr=$2 + local zone_name=$3 + local rule_name="News platform — cache HTML (respect origin)" + + # Fetch existing entrypoint ruleset + local existing + existing=$(curl -fsS "$CF_API/zones/$zone_id/rulesets/phases/http_request_cache_settings/entrypoints" \ + -H "Authorization: Bearer $CF_API_TOKEN" 2>/dev/null || echo '{"result":{}}') + local ruleset_id + ruleset_id=$(echo "$existing" | python3 -c " +import sys, json +d = json.load(sys.stdin) +r = d.get('result', {}) +print(r.get('id', '')) +" 2>/dev/null || echo "") + + local new_rule + new_rule=$(python3 -c " +import json, sys +rule = { + 'action': 'set_cache_settings', + 'action_parameters': { + 'cache': True, + 'origin_cache_control': {'enabled': True} + }, + 'expression': sys.argv[1], + 'description': sys.argv[2], + 'enabled': True +} +print(json.dumps(rule)) +" "$expr" "$rule_name") + + if [ -n "$ruleset_id" ]; then + # Append the new rule to the existing ruleset + local existing_rules + existing_rules=$(echo "$existing" | python3 -c " +import sys, json +d = json.load(sys.stdin) +print(json.dumps(d.get('result', {}).get('rules', []))) +") + local payload + payload=$(python3 -c " +import json, sys +existing = json.loads(sys.argv[1]) +new_rule = json.loads(sys.argv[2]) +# Remove any prior rule with same description to avoid duplicates +rules = [r for r in existing if r.get('description') != new_rule['description']] +rules.append(new_rule) +print(json.dumps({'rules': rules})) +" "$existing_rules" "$new_rule") + curl -fsS -X PATCH "$CF_API/zones/$zone_id/rulesets/$ruleset_id" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$payload" | python3 -m json.tool + else + curl -fsS -X PUT "$CF_API/zones/$zone_id/rulesets/phases/http_request_cache_settings/entrypoints" \ + -H "Authorization: Bearer $CF_API_TOKEN" \ + -H "Content-Type: application/json" \ + -d "$(python3 -c "import json,sys; print(json.dumps({'rules': [json.loads(sys.argv[1])]}))" "$new_rule")" \ + | python3 -m json.tool + fi + echo "Cache rule applied for $zone_name (zone $zone_id)" +} + +echo "==> Resolving zone IDs..." +ZONE_ANDEBOL=$(get_zone_id "andebol.net") +echo " andebol.net : $ZONE_ANDEBOL" +ZONE_NEWS=$(get_zone_id "newsproject.bitreport.pt") +echo " newsproject.bitreport.pt : $ZONE_NEWS" + +echo "==> Applying cache rule for andebol.net..." +EXPR_ANDEBOL='(http.request.method eq "GET") and (http.host in {"andebol.net" "www.andebol.net"}) and not (http.request.uri.path contains "/wp-admin") and not (http.request.uri.path contains "/wp-login.php") and not (http.request.uri.path starts_with "/wp-json/") and not (http.request.uri.path starts_with "/api/")' +upsert_cache_rule "$ZONE_ANDEBOL" "$EXPR_ANDEBOL" "andebol.net" + +echo "==> Applying cache rule for newsproject.bitreport.pt..." +EXPR_NEWS='(http.request.method eq "GET") and (http.host eq "newsproject.bitreport.pt") and not (http.request.uri.path contains "/wp-admin") and not (http.request.uri.path contains "/wp-login.php") and not (http.request.uri.path starts_with "/wp-json/") and not (http.request.uri.path starts_with "/api/")' +upsert_cache_rule "$ZONE_NEWS" "$EXPR_NEWS" "newsproject.bitreport.pt" + +echo "" +echo "==> Waiting 10 s for rule propagation..." +sleep 10 + +echo "==> Verification — double curl per zone:" +for HOST in "https://andebol.net/" "https://newsproject.bitreport.pt/"; do + echo "" + echo "--- $HOST ---" + for i in 1 2; do + echo -n " pass $i: " + curl -fsSI "$HOST" --max-time 15 \ + -w "cf-cache-status=%{header{cf-cache-status}} TTFB=%{time_starttransfer}s\n" \ + -o /dev/null 2>/dev/null + done +done +echo "" +echo "Done. Expected: cf-cache-status=HIT (or STALE/REVALIDATED) on pass 2." +echo "If still DYNAMIC, wait 30 s and re-run the verification block only." diff --git a/deploy/systemd/news-writer-andebol.service b/deploy/systemd/news-writer-andebol.service new file mode 100644 index 0000000..f2499ee --- /dev/null +++ b/deploy/systemd/news-writer-andebol.service @@ -0,0 +1,17 @@ +[Unit] +Description=News Platform — Writer Pipeline (andebol.net) single cycle +After=network.target + +[Service] +Type=oneshot +User=www-data +Group=www-data +WorkingDirectory=/opt/news-platform/writer-pipeline +EnvironmentFile=/etc/news-platform/writer-andebol.env +ExecStart=/usr/bin/node dist/run-cycle.js --site andebol.net --publish-max 3 --shortlist 10 +StandardOutput=journal +StandardError=journal +SyslogIdentifier=news-writer-andebol + +NoNewPrivileges=true +PrivateTmp=true diff --git a/deploy/systemd/news-writer-andebol.timer b/deploy/systemd/news-writer-andebol.timer new file mode 100644 index 0000000..9f1f319 --- /dev/null +++ b/deploy/systemd/news-writer-andebol.timer @@ -0,0 +1,10 @@ +[Unit] +Description=News Platform — Writer Pipeline (andebol.net) daily timer + +[Timer] +OnCalendar=*-*-* 06:00:00 +RandomizedDelaySec=300 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/deploy/systemd/writer-andebol.env.example b/deploy/systemd/writer-andebol.env.example new file mode 100644 index 0000000..139e530 --- /dev/null +++ b/deploy/systemd/writer-andebol.env.example @@ -0,0 +1,12 @@ +# Writer Pipeline — andebol.net environment +# Deploy to /etc/news-platform/writer-andebol.env on the LXC +# Secrets (WP app password) must be kept out of version control. + +NODE_ENV=production + +# WordPress REST API base for andebol.net (Docker compose service, port 8081) +ANDEBOL_WP_BASE=http://127.0.0.1:8081/wp-json + +# WordPress application credentials — generate in WP Users → Application Passwords +ANDEBOL_WP_USER=writer-bot +ANDEBOL_WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx diff --git a/docs/PERFORMANCE_BASELINE.md b/docs/PERFORMANCE_BASELINE.md index 4b3e978..98f8107 100644 --- a/docs/PERFORMANCE_BASELINE.md +++ b/docs/PERFORMANCE_BASELINE.md @@ -4,6 +4,54 @@ **Auditor:** Patrícia Santos (Agent) **Reference:** BIT-2080, docs/architecture.md § 6 +--- + +## Re-Measurement Addendum — 2026-05-12 + +**Date:** 2026-05-12T07:25:00+00:00 +**Auditor:** Rosa Neves (COO Agent) +**Reference:** [BIT-21610](/BIT/issues/BIT-21610) + +### Cache-Control Headers — ✅ RESOLVED + +[BIT-2261](/BIT/issues/BIT-2261) (Cache-Control on page responses) is **done**. Headers are now emitted on all Astro page routes: + +``` +cache-control: s-maxage=60, stale-while-revalidate=300 +``` + +Confirmed on both domains (2026-05-12): +- `andebol.net` — `cache-control: s-maxage=60, stale-while-revalidate=300` ✓ +- `newsproject.bitreport.pt` — `cache-control: s-maxage=60, stale-while-revalidate=300` ✓ + +### TTFB Re-Measurement + +Measurements repeated 2026-05-12T10:50 UTC (3 samples each): + +| Domain | Min TTFB | Median TTFB | Max TTFB | cf-cache-status | +|--------|----------|-------------|----------|-----------------| +| andebol.net | 0.181s | 0.233s | 0.396s | DYNAMIC | +| newsproject.bitreport.pt | 0.229s | 0.272s | 0.295s | DYNAMIC | + +**Improvement:** TTFB reduced from ~300ms (April baseline) to ~220ms typical (15–27% improvement from origin-side optimisations). Cache-Control headers confirmed present on every request. + +### Remaining Gap — Cloudflare HTML Caching + +`cf-cache-status: DYNAMIC` persists despite correct `s-maxage=60` headers. Root cause: **Cloudflare does not cache HTML by default**; a Cloudflare Cache Rule ("Cache Level: Cache Everything") is required to enable CDN-layer HTML caching. + +| Metric | Target | Actual | Status | +|--------|--------|--------|--------| +| TTFB (cache HIT) | < 30 ms | ~220 ms | ❌ Cloudflare Cache Rule missing | +| TTFB (cache MISS) | < 200 ms | ~220 ms | ⚠️ Close; origin at 220ms | +| Cache-Control headers | present | present | ✅ | +| cf-cache-status | HIT | DYNAMIC | ❌ Needs Cloudflare Cache Rule | + +**Next action:** Apply the **Cache Rules** spec in [`docs/deployment.md`](deployment.md) (section *Cloudflare — HTML edge cache*) on each production zone (`andebol.net`, `newsproject.bitreport.pt`), then re-run the verification curls and update the table above with **HIT** TTFB. Tracked as [BIT-21847](/BIT/issues/BIT-21847) (child of BIT-21610). + +**Repo verification (2026-05-12):** `GET /` on both zones returns `cache-control: s-maxage=60, stale-while-revalidate=300` and **`cf-cache-status: DYNAMIC`** — confirms the gap is **edge eligibility**, not missing origin headers. + +**Continuation check (2026-05-12, post–[BIT-21912](/BIT/issues/BIT-21912)):** repeat double-`GET /` from CI runner — still **`DYNAMIC`** on both hosts; TTFB samples ~0.18–0.46s first hop, ~0.24–0.39s second — **no edge HIT** until DevOps applies the dashboard rule. Parent **BIT-21847** set **`blocked`** pending child closure. + ## Executive Summary Baseline performance audit reveals **critical cache implementation gap**: Neither production domain is returning `Cache-Control` headers, preventing Cloudflare edge caching. TTFB measurements show ~300ms for all requests instead of target <30ms (cache HIT) / <200ms (cache MISS). diff --git a/docs/PROJECT_STATUS.md b/docs/PROJECT_STATUS.md index dbbac95..c3e93bb 100644 --- a/docs/PROJECT_STATUS.md +++ b/docs/PROJECT_STATUS.md @@ -1,6 +1,6 @@ # Estado do projecto — [CLI] News Platform -Documento de **paridade entre objectivos e entregas** no repositório **news-platform** (workspace Paperclip **[CLI] News platform**, `urlKey` **cli-news-platform**). Complementa o índice de runbooks em [`docs/runbooks/README.md`](runbooks/README.md) e a arquitectura em [`docs/architecture.md`](architecture.md). O sweep activo no board é [BIT-2030](/BIT/issues/BIT-2030) (governance 2026-04); [BIT-1911](/BIT/issues/BIT-1911) permanece referência histórica do ciclo anterior. +Documento de **paridade entre objectivos e entregas** no repositório **news-platform** (workspace Paperclip **[CLI] News platform**, `urlKey` **cli-news-platform**). Complementa o índice de runbooks em [`docs/runbooks/README.md`](runbooks/README.md) e a arquitectura em [`docs/architecture.md`](architecture.md). O sweep de governance **[BIT-2030](/BIT/issues/BIT-2030)** (2026-04) foi **concluído no board** com todos os filhos directos em estado terminal (`done`); [BIT-1911](/BIT/issues/BIT-1911) permanece referência histórica do ciclo anterior. ## Objectivos do projecto @@ -26,7 +26,7 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`]( | # | Objectivo | Estado | Rastreio principal | |---|-----------|--------|--------------------| | 1 | Plataforma multi-domínio | ✅ Entregue | [BIT-345](/BIT/issues/BIT-345), [BIT-494](/BIT/issues/BIT-494)–[BIT-497](/BIT/issues/BIT-497) | -| 2 | Frontend SSR performante | ⏳ Auditoria pendente | [BIT-349](/BIT/issues/BIT-349) — entregue; métricas a verificar em [BIT-2080](/BIT/issues/BIT-2080) | +| 2 | Frontend SSR performante | ✅ Auditoria + validação prod encerradas no board | [BIT-349](/BIT/issues/BIT-349) — entregue; [BIT-2080](/BIT/issues/BIT-2080) / [BIT-21610](/BIT/issues/BIT-21610) `done` — [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) | | 3 | Bridge Fastify + Redis | ✅ Entregue | [BIT-350](/BIT/issues/BIT-350), [BIT-2076](/BIT/issues/BIT-2076) (Redis extension fix) | | 4 | WordPress headless | ✅ Entregue | [BIT-351](/BIT/issues/BIT-351) | | 5 | SEO de primeira classe | ✅ Entregue | [BIT-349](/BIT/issues/BIT-349) — SSR, JSON-LD, OG, sitemap, robots | @@ -35,7 +35,7 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`]( | 8 | Monitorização com alertas | ✅ Entregue | [BIT-744](/BIT/issues/BIT-744), [BIT-746](/BIT/issues/BIT-746) — healthcheck + Ntfy | | 9 | Domínio andebol.net | ✅ Entregue | [BIT-497](/BIT/issues/BIT-497), [BIT-507](/BIT/issues/BIT-507), [BIT-584](/BIT/issues/BIT-584)–[BIT-626](/BIT/issues/BIT-626) | | 10 | Agregador multi-source | ✅ Entregue | [BIT-709](/BIT/issues/BIT-709)–[BIT-713](/BIT/issues/BIT-713) | -| 11 | Pipeline de escrita AI | ⏳ Automação pendente | [BIT-741](/BIT/issues/BIT-741) — pipeline entregue; timer systemd em [BIT-2079](/BIT/issues/BIT-2079) | +| 11 | Pipeline de escrita AI | ✅ Automação entregue | [BIT-741](/BIT/issues/BIT-741) — pipeline; timer systemd [BIT-2079](/BIT/issues/BIT-2079) `done` | | 12 | Internacionalização PT-PT | ✅ Entregue | [BIT-739](/BIT/issues/BIT-739) | ## Árvore do repositório (resumo) @@ -70,10 +70,13 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`]( | Issue | Título (resumo) | Estado | Relação | |-------|-----------------|--------|---------| -| [BIT-2030](/BIT/issues/BIT-2030) | [Governance] Docs vs objectives sweep — cli-news-platform | `done` | **Pai (actual)** — sweep 2026-04 | -| [BIT-2078](/BIT/issues/BIT-2078) | Add docs/PROJECT_STATUS.md — objectives vs delivery matrix | `todo` | **Filho** — este ficheiro | -| [BIT-2079](/BIT/issues/BIT-2079) | Automate andebol.net writer pipeline — systemd timer on LXC | `todo` | **Filho** — automação do pipeline de escrita | -| [BIT-2080](/BIT/issues/BIT-2080) | Core Web Vitals audit — verify TTFB/LCP/Lighthouse targets | `todo` | **Filho** — auditoria de performance vs spec | +| [BIT-2030](/BIT/issues/BIT-2030) | [Governance] Docs vs objectives sweep — cli-news-platform | `done` | **Pai** — sweep 2026-04 (todos os filhos directos `done`) | +| [BIT-2078](/BIT/issues/BIT-2078) | Add docs/PROJECT_STATUS.md — objectives vs delivery matrix | `done` | **Filho** — este ficheiro | +| [BIT-2079](/BIT/issues/BIT-2079) | Automate andebol.net writer pipeline — systemd timer on LXC | `done` | **Filho** — automação LXC | +| [BIT-2080](/BIT/issues/BIT-2080) | Core Web Vitals audit — verify TTFB/LCP/Lighthouse targets | `done` | **Filho** — baseline em [`PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) | +| [BIT-21610](/BIT/issues/BIT-21610) | Prod validation — Cache-Control / TTFB vs PERFORMANCE_BASELINE | `done` | **Filho** — fecho pós-auditoria (Nginx / edge / medição) | +| [BIT-21770](/BIT/issues/BIT-21770) | Recover stalled issue BIT-2030 | `done` | **Filho (operação)** — recuperação Paperclip | +| [BIT-21615](/BIT/issues/BIT-21615) | [Fila escalation] BIT-2030 parado (orphan_lock) | `done` | **Filho (operação)** — fila pulse; resolvido | | [BIT-1911](/BIT/issues/BIT-1911) | [Governance] Docs vs objectives sweep — cli-news-platform (ciclo anterior) | *histórico* | **Pai legado** — gerou BIT-1951/1952/1953 | | [BIT-1951](/BIT/issues/BIT-1951) | Add docs/runbooks/README.md | `done` | **Filho (legado)** — índice runbooks | | [BIT-1952](/BIT/issues/BIT-1952) | Expand root README doc index | `done` | **Filho (legado)** — índice completo docs/ | @@ -81,10 +84,7 @@ Alinhados à descrição do projecto no Paperclip e ao [`docs/architecture.md`]( ## Entregáveis em falta / work-in-progress -| Entregável | Rastreio | Estado | -|------------|----------|--------| -| Auditoria Core Web Vitals (TTFB/LCP/Lighthouse vs spec) | [BIT-2080](/BIT/issues/BIT-2080) — owner: Nelson Alves | ⏳ `todo` | -| Systemd timer para pipeline de escrita andebol.net no LXC | [BIT-2079](/BIT/issues/BIT-2079) — owner: Tiago Neves | ⏳ `todo` | +Nenhum filho directo aberto sob **[BIT-2030](/BIT/issues/BIT-2030)** (sweep governance 2026-04 encerrado). Novo trabalho de plataforma deve abrir issues no projecto **cli-news-platform** com workspace correcto. ## Referências rápidas diff --git a/docs/deployment.md b/docs/deployment.md index 4568c38..40037fc 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -101,6 +101,64 @@ The checked-in `deploy/nginx/newsproject.bitreport.pt.conf` proxies WordPress on --- +## Cloudflare — HTML edge cache (Cache Rules) + +Public HTML is served through Cloudflare. **Default behaviour:** Cloudflare marks HTML as **not eligible** for the edge cache unless a **Cache Rule** says otherwise, so responses stay `cf-cache-status: DYNAMIC` even when the origin sends `Cache-Control: s-maxage=60, stale-while-revalidate=300` (see [`docs/PERFORMANCE_BASELINE.md`](PERFORMANCE_BASELINE.md) § *Remaining Gap — Cloudflare HTML Caching*). + +This is **board / DevOps configuration** in the Cloudflare dashboard (or API/Terraform) for **each zone** that fronts a news-platform hostname — today **`andebol.net`** and **`newsproject.bitreport.pt`**. Repeat the same rule on both zones if they use separate zones. + +### Dashboard (canonical) + +1. Cloudflare dashboard → select the **zone** → **Caching** → **Cache Rules** → **Create rule**. +2. **Rule name:** e.g. `News platform — cache HTML (respect origin)`. +3. **When incoming requests match** — **Custom filter expression** (Expression Editor). Use **one rule per zone**; expressions below mirror [BIT-21847](/BIT/issues/BIT-21847) (exclude `wp-admin`, `wp-login`, `wp-json`, **`/api/`**). + +**Zone `andebol.net`:** + +```txt +(http.request.method eq "GET") and +(http.host in {"andebol.net" "www.andebol.net"}) and +not (http.request.uri.path contains "/wp-admin") and +not (http.request.uri.path contains "/wp-login.php") and +not (http.request.uri.path starts_with "/wp-json/") and +not (http.request.uri.path starts_with "/api/") +``` + +**Zone `newsproject.bitreport.pt`:** + +```txt +(http.request.method eq "GET") and +(http.host eq "newsproject.bitreport.pt") and +not (http.request.uri.path contains "/wp-admin") and +not (http.request.uri.path contains "/wp-login.php") and +not (http.request.uri.path starts_with "/wp-json/") and +not (http.request.uri.path starts_with "/api/") +``` + +Extend the hostname list when new production hostnames are added under `config/domains/*.json`. The **`/api/`** exclusion reserves any future first-party API surface on the public hostname from edge HTML caching; adjust if a path must remain cacheable. + +4. **Then** (cache settings): + + - **Cache eligibility:** **Eligible for cache** (this is the supported replacement for the legacy Page Rule “Cache Everything” for HTML; see Cloudflare’s doc [*Cache Level (Cache Everything)*](https://developers.cloudflare.com/cache/how-to/cache-rules/examples/cache-everything/)). + - **Edge TTL / origin behaviour:** leave **Origin Cache Control** effective so Cloudflare honours the Astro `s-maxage` / `stale-while-revalidate` headers (see [*Origin Cache Control*](https://developers.cloudflare.com/cache/concepts/cache-control/)). Do **not** set a fixed Edge TTL that overrides those values unless there is an explicit product decision. + +5. **Ordering:** place any **Bypass cache** rules (preview, authenticated staff, debug) **above** this rule so they win first. + +6. **Purge after deploys:** continue to use the existing bridge / WordPress invalidation path (`docs/architecture.md` § *Cache Invalidation*). After material HTML or config changes, purge affected URLs or prefixes in Cloudflare if the edge still serves stale content beyond `s-maxage`. + +### Verification (operator) + +Second request should show a warm edge when the rule is active: + +```bash +curl -fsSI "https://andebol.net/" | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' +curl -fsSI "https://andebol.net/" | tr -d '\r' | egrep -i '^(cf-cache-status|cache-control|age):' +``` + +Expect `cf-cache-status: HIT` (or `STALE` / `REVALIDATED` per Cloudflare semantics) on the repeat, and `cache-control` unchanged from origin. Until the rule exists, both calls return **`DYNAMIC`** despite valid `Cache-Control`. + +--- + ## WordPress (Docker Compose) A stack real está versionada em **`wordpress/docker-compose.yml`** (não duplicar aqui — evita deriva face à produção). @@ -157,6 +215,7 @@ pm2 startup - [ ] NPM configured for HTTPS (board): hostname **`newsproject.bitreport.pt`** → CT port 80 - [ ] Smoke: `BASE_URL=https://newsproject.bitreport.pt bash deploy/scripts/smoke-newsproject.sh` (or `BASE_URL=http://127.0.0.1` on the CT) - [ ] Sitemap accessible at `/sitemap.xml` +- [ ] **Cloudflare (board):** per zone, Cache Rule for HTML edge cache (section **Cloudflare — HTML edge cache** above); verify `cf-cache-status` flips from `DYNAMIC` to `HIT` on repeat `GET` to `/` --- @@ -174,6 +233,59 @@ After the first manual bootstrap, pushes to `main` can trigger a pull + selectiv --- +## Writer Pipeline — andebol.net (systemd timer) + +The writer pipeline runs as a `oneshot` systemd service triggered daily at 06:00 UTC. + +### Files + +| Repo path | CT destination | +|-----------|----------------| +| `deploy/systemd/news-writer-andebol.service` | `/etc/systemd/system/news-writer-andebol.service` | +| `deploy/systemd/news-writer-andebol.timer` | `/etc/systemd/system/news-writer-andebol.timer` | +| `deploy/systemd/writer-andebol.env.example` | `/etc/news-platform/writer-andebol.env` (fill secrets) | + +### Install on the CT + +```bash +# 1. Copy env template and fill in WP credentials +sudo cp /opt/news-platform/deploy/systemd/writer-andebol.env.example \ + /etc/news-platform/writer-andebol.env +sudo chmod 640 /etc/news-platform/writer-andebol.env +sudo chown root:www-data /etc/news-platform/writer-andebol.env +# Edit ANDEBOL_WP_USER and ANDEBOL_WP_APP_PASSWORD + +# 2. Install units +sudo cp /opt/news-platform/deploy/systemd/news-writer-andebol.service \ + /etc/systemd/system/ +sudo cp /opt/news-platform/deploy/systemd/news-writer-andebol.timer \ + /etc/systemd/system/ +sudo systemctl daemon-reload + +# 3. Enable and start the timer +sudo systemctl enable --now news-writer-andebol.timer + +# 4. Verify +systemctl list-timers news-writer-andebol.timer +``` + +### Manual test run + +```bash +sudo systemctl start news-writer-andebol.service +journalctl -u news-writer-andebol.service -n 50 +``` + +### Log tailing + +```bash +journalctl -f -u news-writer-andebol.service +``` + +Cycle output (metrics JSON) is also appended to `/opt/news-platform/writer-pipeline/var/metrics.jsonl`. + +--- + ## Future: Multi-Container When the platform scales beyond a single test container, each service moves to its own LXC or VM: diff --git a/docs/runbooks/README.md b/docs/runbooks/README.md index 55373df..67ea06c 100644 --- a/docs/runbooks/README.md +++ b/docs/runbooks/README.md @@ -2,6 +2,8 @@ Operational procedures for this repository. For company-wide runbooks (Paperclip host, Gitea, fleet automation), see the **paperclip** meta-repo: `docs/runbooks/README.md`. +These runbooks implement **operational depth** for objectives already covered at a high level in [`docs/PROJECT_STATUS.md`](../PROJECT_STATUS.md) and [`docs/architecture.md`](../architecture.md): incident and monitoring procedures map primarily to **monitorização com alertas** (objective #8) and **deploy / LXC** operations (objectives #6–#7). + ## In this repo | Topic | Where |