mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-06 07:59:47 +01:00
The web inferred 'Fleet Runner online' from the freshness of a 5-min runtime-state heartbeat (offline if >8min stale), so a healthy runner looked dead for minutes after any restart. Presence is now a property of the live runner<->bridge SSE connection instead of a timer. - bridge: runner connections tag themselves ?client=runner; on connect/disconnect the bridge upserts runner_presence and pg_notify's the web stream channel. Boot resets all counts so a crashed bridge can't leave stale 'connected'. - web: /control/stream carries live runnerConnected; the badge flips in <1s. ADDITIVE: online = connected OR heartbeat-fresh, so the current (untagged) runner keeps working until the desktop rebuild ships. Cutover (drop heartbeat + long-poll) is staged separately. - desktop runner tags its bridge connection ?client=runner. Docs: docs/architecture/connection-presence.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
17 lines
840 B
SQL
17 lines
840 B
SQL
-- Connection-based runner presence (replaces the heartbeat-freshness guess).
|
|
-- Written by the bridge on runner SSE connect/disconnect.
|
|
-- Idempotent + additive: safe to apply to a live DB; nothing reads it until
|
|
-- the web cutover. See docs/architecture/connection-presence.md.
|
|
CREATE TABLE IF NOT EXISTS "runner_presence" (
|
|
"user_id" uuid PRIMARY KEY NOT NULL,
|
|
"connection_count" integer DEFAULT 0 NOT NULL,
|
|
"connected" boolean DEFAULT false NOT NULL,
|
|
"connected_at" timestamp with time zone,
|
|
"last_change_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
DO $$ BEGIN
|
|
ALTER TABLE "runner_presence" ADD CONSTRAINT "runner_presence_user_id_users_id_fk"
|
|
FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;
|
|
EXCEPTION WHEN duplicate_object THEN NULL; END $$;
|