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:
12
server.ts
12
server.ts
@@ -4,7 +4,7 @@ import { log } from "./src/log.ts";
|
||||
|
||||
const router = new Router();
|
||||
|
||||
const PAGINATION = 20
|
||||
const PAGINATION = 20;
|
||||
|
||||
router.get("/", (ctx) => {
|
||||
ctx.response.body = "Hello world";
|
||||
@@ -48,8 +48,14 @@ const app = new Application();
|
||||
|
||||
app.use(async (ctx, next) => {
|
||||
ctx.response.headers.set("Access-Control-Allow-Origin", "*");
|
||||
ctx.response.headers.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
||||
ctx.response.headers.set("Access-Control-Allow-Headers", "Content-Type, Authorization");
|
||||
ctx.response.headers.set(
|
||||
"Access-Control-Allow-Methods",
|
||||
"GET, POST, PUT, DELETE, OPTIONS",
|
||||
);
|
||||
ctx.response.headers.set(
|
||||
"Access-Control-Allow-Headers",
|
||||
"Content-Type, Authorization",
|
||||
);
|
||||
if (ctx.request.method === "OPTIONS") {
|
||||
ctx.response.status = 204;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user