robustness: split jetstream into own container, add cursor persistence

Jetstream was running backgrounded in the same container as the API server,
so crashes went undetected and Docker never restarted it. Now each process
runs as a separate docker-compose service with independent restart policies.

Also adds cursor persistence to SQLite (saved every 5s) so restarts resume
from where they left off, moves event destructuring inside try/catch blocks,
and adds global unhandled error/rejection handlers for crash visibility.
This commit is contained in:
Julien Calixte
2026-02-17 01:17:42 +01:00
parent 1a7841b728
commit c84b4c5f97
9 changed files with 108 additions and 35 deletions

View File

@@ -57,8 +57,22 @@ export const deleteNote = ({ did, rkey }: { did: string; rkey: string }) => {
db.query("DELETE FROM note WHERE did = ? AND rkey = ?", [did, rkey]);
};
export const getCursor = (): string | undefined => {
const rows = db.query<[string]>(
"SELECT value FROM state WHERE key = 'cursor'",
);
return rows[0]?.[0];
};
export const saveCursor = (cursor: number) => {
db.query(
"INSERT OR REPLACE INTO state (key, value) VALUES ('cursor', ?)",
[String(cursor)],
);
};
export const upsertNote = (note: Note) => {
const now = new Date().toISOString()
const now = new Date().toISOString();
db.query(
`