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.
22 lines
377 B
TypeScript
22 lines
377 B
TypeScript
import { db } from "../data/db.ts";
|
|
|
|
db.execute(`
|
|
CREATE TABLE IF NOT EXISTS note (
|
|
title TEXT NOT NULL,
|
|
publishedAt DATETIME,
|
|
createdAt DATETIME NOT NULL,
|
|
did TEXT NOT NULL,
|
|
rkey TEXT NOT NULL,
|
|
PRIMARY KEY (did, rkey)
|
|
);
|
|
`);
|
|
|
|
db.execute(`
|
|
CREATE TABLE IF NOT EXISTS state (
|
|
key TEXT PRIMARY KEY,
|
|
value TEXT NOT NULL
|
|
);
|
|
`);
|
|
|
|
db.close();
|