Ports push_scripts.sh (1497 lines of bash) to a SvelteKit + SQLite web app that manages a fleet of T5 Plutonium servers running on Komodo. Same push and beta workflow as the shell script, with a live SSE pipeline view, a !rt-token-gated auth modal that hard-pauses deployments on stale tokens, per-file audit diffs, and a Komodo-container deployment target. - Push/beta engines port the exact filter, held-by-beta, conflict, and stale-backup rules from the shell script - SQLite (better-sqlite3) replaces script_metadata.json; a one-shot importer moves legacy state over on first boot - 16 vitest tests cover push add/update/skip, beta open→rollback, open→promote, conflict guards, sweep frozen/manual branches, and IW4M login/status parsing - docker/ + komodo/stack.toml deploy as a managed container on the same host as the game servers, /root/zombies bind-mounted at the same path the shell script used
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { json } from '@sveltejs/kit';
|
|
import { db } from '$lib/server/db/index.js';
|
|
|
|
export async function GET({ url }: { url: URL }) {
|
|
const activeOnly = url.searchParams.get('active') === 'true';
|
|
|
|
const deployments = db()
|
|
.prepare(
|
|
`SELECT id, action, started_at, finished_at, triggered_by
|
|
FROM deployments
|
|
ORDER BY started_at DESC
|
|
LIMIT 500`
|
|
)
|
|
.all() as Array<{
|
|
id: string;
|
|
action: string;
|
|
started_at: string;
|
|
finished_at: string | null;
|
|
triggered_by: string | null;
|
|
}>;
|
|
|
|
const serversByDep = db()
|
|
.prepare(
|
|
`SELECT deployment_id, server, files_changed, restart_state, players, checked_at, restarted_at, attempts, error
|
|
FROM deployment_servers`
|
|
)
|
|
.all() as Array<{
|
|
deployment_id: string;
|
|
server: string;
|
|
files_changed: number;
|
|
restart_state: string;
|
|
players: number | null;
|
|
checked_at: string | null;
|
|
restarted_at: string | null;
|
|
attempts: number;
|
|
error: string | null;
|
|
}>;
|
|
|
|
const grouped = new Map<string, typeof serversByDep>();
|
|
for (const s of serversByDep) {
|
|
const arr = grouped.get(s.deployment_id) ?? [];
|
|
arr.push(s);
|
|
grouped.set(s.deployment_id, arr);
|
|
}
|
|
|
|
const rows = deployments
|
|
.map((d) => ({ ...d, servers: grouped.get(d.id) ?? [] }))
|
|
.filter((d) => (activeOnly ? d.servers.some((s) => s.restart_state === 'pending' || s.restart_state === 'failed') : true));
|
|
|
|
return json({ deployments: rows });
|
|
}
|