Skip to content

ops(live-worker): Railway-Worker-Config + Etappe-3-Doku-Korrekturen - #50

Merged
patricznr1 merged 1 commit into
mainfrom
ops/live-worker-railway-config
Jun 25, 2026
Merged

ops(live-worker): Railway-Worker-Config + Etappe-3-Doku-Korrekturen#50
patricznr1 merged 1 commit into
mainfrom
ops/live-worker-railway-config

Conversation

@patricznr1

@patricznr1 patricznr1 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Kontext

Der Live-Daten-Stream-Worker (PR #47) ist auf Railway scharf geschaltet (Etappe 3): eigener Service live-worker, Singleton (replicas=1), Restart ON_FAILURE, kein Healthcheck. Live verifiziert — max(time) der readings wandert mit der Wall-Clock (Lücke < 1 Tick), /overview → stream.active = true, Neustart resumed ohne Doppel (dup = 0).

Dieser PR ist der reine Ops-/Doku-Nachzug dazu — kein App-Code-Change.

Was drin ist

railway.worker.toml (neu)

Config-as-code des Worker-Service: startCommand = live_worker --interval-seconds 60, kein Healthcheck, Restart ON_FAILURE. Der Worker-Service zeigt via Service-Setting „Config-as-code file" (GraphQL railwayConfigFile) auf diese Datei — das Root-railway.toml ist Backend-only (alembic + uvicorn + Healthcheck /health) und config-as-code überschreibt Dashboard-Settings, würde den Worker also sonst als zweiten Web-Server starten.

DEPLOY.md §8 — drei beim Scharfschalten verifizierte Korrekturen

  1. §8.1 — --anchor-now ist additiv, kein In-Place-Verschieben. Auf einer bereits geseedeten DB erzeugt es Doppeldaten (kein Truncate/Upsert im readings-Pfad). Jetzt klar dokumentiert: nur auf frischer DB oder nach explizitem TRUNCATE der Daten-Ebene (Truncate-Set + Hypertable-Backup-Hinweis, da pg_dump -t readings die Chunks nicht erfasst). Nicht-destruktiver Default-Weg --max-catchup-ticks ergänzt.
  2. §8.2/§8.1 — railway ssh statt railway run. railway run läuft lokal; railway.internal ist von dort nicht erreichbar — die Live-DB nur über Private Networking im Container.
  3. §8.3 — config-as-code-file-Mechanismus + Cross-Service-Referenz ${{backend.FOREMAN_PSEUDO_KEY_v1}} für den Pseudo-Key (kein Secret-Kopieren, konsistente Pseudonyme); JWT_SECRET braucht der Worker nicht.

Hinweis

Der laufende live-worker-Service wurde via railway up-Upload scharf geschaltet (die railway.worker.toml lag im Upload-Snapshot). Nach Merge kann der Service optional auf GitHub-Source umgestellt werden — dann liegt die Config in main.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Die Anleitung für den Live-Daten-Stream-Worker wurde deutlich erweitert und klarer strukturiert.
    • Es gibt jetzt präzisere Schritte für Trockenlauf, Verifikation und den Betrieb als dauerhaften Worker-Service.
    • Zusätzlich wurden Hinweise für Backup, Wiederherstellung und die Auswahl zwischen sicherem und destruktivem Vorgehen ergänzt.
  • New Features
    • Ein separates Worker-Setup wurde ergänzt, um den Stream-Worker eigenständig zu deployen und zu betreiben.

Der Live-Stream-Worker läuft jetzt als eigener Railway-Service (Etappe 3
scharf geschaltet). Dieser Nachzug fixiert die dafür nötige Config-as-code
und korrigiert zwei Doku-Fallen, die beim Scharfschalten auffielen:

- NEU railway.worker.toml: Deploy-Config des Worker-Service (startCommand
  live_worker, KEIN Healthcheck, restart ON_FAILURE). Der Worker-Service
  zeigt via "Config-as-code file"-Setting (GraphQL railwayConfigFile) auf
  diese Datei — das Root-railway.toml ist Backend-only (uvicorn + /health)
  und würde den Worker sonst als zweiten Web-Server starten.

- DEPLOY.md §8.1: --anchor-now ist ein ADDITIVES Backfill, kein In-Place-
  Verschieben. Auf einer bereits geseedeten DB entstehen Doppeldaten (kein
  Truncate/Upsert im readings-Schreibpfad). Nur auf frischer DB oder nach
  explizitem TRUNCATE der Daten-Tabellen nutzen — Truncate-Set + Hypertable-
  Backup-Hinweis ergänzt. Nicht-destruktiver Alternativweg --max-catchup-ticks
  dokumentiert.

- DEPLOY.md §8.2: railway ssh (im Container) statt railway run (lokal) —
  railway.internal ist lokal nicht erreichbar.

- DEPLOY.md §8.3: config-as-code-file-Mechanismus + Cross-Service-Referenz
  für FOREMAN_PSEUDO_KEY_v1 (kein Secret-Kopieren) dokumentiert.

Reiner Ops-/Doku-Nachzug, kein App-Code-Change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Die Stage-3-Anleitung wurde um die Entscheidung zwischen --max-catchup-ticks und --anchor-now, den Trockenlauf, eine separate Railway-Worker-Konfiguration und erweiterte Verifikationsschritte ergänzt.

Changes

Live-Daten-Stream-Worker

Layer / File(s) Summary
History anchoring
DEPLOY.md
Die Anleitung für 8.1 trennt nicht-destruktives Catchup-Kappen von destruktivem Re-Seed und ergänzt Backup- sowie TRUNCATE-Schritte.
Dry-run checks
DEPLOY.md
8.2 ergänzt Container-Hinweise und konkrete Prüfbedingungen für Zeitstempel, Dublettenfreiheit und Live-Update-Anzeige.
Worker service config
DEPLOY.md, railway.worker.toml
8.3 beschreibt den Worker als separaten Railway-Service mit railway.worker.toml; 8.4 ergänzt die Prüfungen für Logs, WS-Status und DB-Historie.

Sequence Diagram(s)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Ich hüpf durch Stage Drei, ganz flink und klar,
mit anchor-now wird die Historie offenbar.
Der Worker summt im Container warm,
die Checks sind wach, die Logs ganz charm.
Oh frische Daten, hoppela!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel nennt passend die Live-Worker-Railway-Konfiguration und die Etappe-3-Dokumentationskorrekturen.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ops/live-worker-railway-config

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DEPLOY.md`:
- Around line 309-311: The documented Start-Command and the actual worker config
are out of sync. Update the DEPLOY.md guidance around the worker setup to match
the exact command used by railway.worker.toml via the live_worker configuration,
and make sure the runbook references the same executable invocation as the
service settings so the doc and deployed behavior stay aligned.

In `@railway.worker.toml`:
- Around line 27-28: The deployment docs currently imply unlimited automatic
restarts, but the Railway worker config uses restartPolicyType with
restartPolicyMaxRetries set to 10, so the worker will stop auto-restarting after
10 failed exits. Update the documentation or any related explanation to describe
this bounded retry behavior accurately, using the restartPolicyType and
restartPolicyMaxRetries settings as the reference points.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a46c1cb5-e3fb-416d-874e-a63641a35c77

📥 Commits

Reviewing files that changed from the base of the PR and between 0c8c71f and 261bc87.

📒 Files selected for processing (2)
  • DEPLOY.md
  • railway.worker.toml

Comment thread DEPLOY.md
Comment on lines +309 to +311
> uvicorn** starten. Lösung: Der Worker-Service zeigt via **„Config-as-code file"**
> (Service-Settings; GraphQL-Feld `railwayConfigFile`) auf **`/railway.worker.toml`**
> (Start-Command `live_worker`, kein Healthcheck, Restart `ON_FAILURE`).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Start-Command in Doku und Config angleichen.

Line 311 nennt live_worker, aber die produktive Config startet aktuell mit python -m foreman.adapters.simulation.live_worker --interval-seconds 60 (siehe railway.worker.toml, Line 24). Bitte auf einen exakten Command vereinheitlichen, damit Runbook und Service-Verhalten nicht auseinanderlaufen.

Vorschlag (Doku präzisieren)
-(Start-Command `live_worker`, kein Healthcheck, Restart `ON_FAILURE`).
+(Start-Command `python -m foreman.adapters.simulation.live_worker --interval-seconds 60`,
+kein Healthcheck, Restart `ON_FAILURE`).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
> uvicorn** starten. Lösung: Der Worker-Service zeigt via **„Config-as-code file"**
> (Service-Settings; GraphQL-Feld `railwayConfigFile`) auf **`/railway.worker.toml`**
> (Start-Command `live_worker`, kein Healthcheck, Restart `ON_FAILURE`).
> uvicorn** starten. Lösung: Der Worker-Service zeigt via **„Config-as-code file"**
> (Service-Settings; GraphQL-Feld `railwayConfigFile`) auf **`/railway.worker.toml`**
> (Start-Command `python -m foreman.adapters.simulation.live_worker --interval-seconds 60`,
> kein Healthcheck, Restart `ON_FAILURE`).
🧰 Tools
🪛 LanguageTool

[typographical] ~309-~309: Zeichen ohne sein Gegenstück: ‚“‘ scheint zu fehlen
Context: ... Lösung: Der Worker-Service zeigt via „Config-as-code file" > (Service-Settin...

(DE_UNPAIRED_QUOTES)


[style] ~310-~310: Möchten Sie die modernere Schreibweise „GrafQL-Feld“ verwenden?
Context: ...ig-as-code file"** > (Service-Settings; GraphQL-Feld railwayConfigFile) auf **`/railway.wo...

(F_ANSTATT_PH)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DEPLOY.md` around lines 309 - 311, The documented Start-Command and the
actual worker config are out of sync. Update the DEPLOY.md guidance around the
worker setup to match the exact command used by railway.worker.toml via the
live_worker configuration, and make sure the runbook references the same
executable invocation as the service settings so the doc and deployed behavior
stay aligned.

Comment thread railway.worker.toml
Comment on lines +27 to +28
restartPolicyType = "ON_FAILURE"
restartPolicyMaxRetries = 10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

Railway config-as-code: What exactly does deploy.restartPolicyMaxRetries do with restartPolicyType=ON_FAILURE, and does the service stop permanently after reaching the retry limit?

💡 Result:

When using Railway's Config-as-Code to set restartPolicyType to ON_FAILURE, the restartPolicyMaxRetries setting defines the maximum number of times Railway will attempt to automatically restart your service if it exits with a non-zero exit code [1][2][3]. Yes, the service stops permanently after reaching this retry limit [2][3]. Specifically, if the service crashes and exceeds the configured restartPolicyMaxRetries limit, the deployment status is changed to Crashed, and the service will no longer attempt to restart automatically [2][3]. Once in this Crashed state, you must manually intervene—such as by clicking the "Restart" button in the Railway dashboard or triggering a redeploy—to bring the service back online [2][3]. In summary, the retry limit serves as a safeguard to prevent infinite restart loops for services that are fundamentally failing. If a process repeatedly exits with errors, Railway halts the cycle to prevent further resource consumption and to notify you of the failure via webhooks and email [2][3].

Citations:


restartPolicyMaxRetries begrenzt Auto-Restarts auf 10 Versuche
restartPolicyType = "ON_FAILURE" startet nur bei Fehl-Exits neu; nach 10 Fehlstarts wechselt Railway auf Crashed und startet nicht mehr automatisch. Wenn der Worker dauerhaft laufen soll, sollte die Deploy-Doku das nicht als unbegrenztes Restart-Verhalten beschreiben.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@railway.worker.toml` around lines 27 - 28, The deployment docs currently
imply unlimited automatic restarts, but the Railway worker config uses
restartPolicyType with restartPolicyMaxRetries set to 10, so the worker will
stop auto-restarting after 10 failed exits. Update the documentation or any
related explanation to describe this bounded retry behavior accurately, using
the restartPolicyType and restartPolicyMaxRetries settings as the reference
points.

@patricznr1
patricznr1 merged commit 43c3b13 into main Jun 25, 2026
3 checks passed
@patricznr1
patricznr1 deleted the ops/live-worker-railway-config branch June 25, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant