Files
photoreport/apps/api/src/server.ts
T
1sonhador 1fa97ca3bb
ci / rust (push) Successful in 4m11s
ci / typescript (push) Successful in 7m20s
Keep ZeroZero uploads alive when the worker is busy.
Cap face analysis at what one Node thread can commit, prefer IPv4 so a dead IPv6 route cannot fail the fetch, and leave a photo on the desk when ZeroZero says it is already there. Desktop originals go out one at a time so the app does not freeze on "A enviar…".
2026-10-15 20:14:04 +01:00

28 lines
801 B
TypeScript

import { preferIpv4 } from "./lib/prefer-ipv4.js";
import { buildApp, reporterFor } from "./app.js";
import { loadConfig } from "./config.js";
import { createDb } from "./db.js";
preferIpv4();
const config = loadConfig();
const db = createDb(config.DATABASE_URL);
const reporter = reporterFor(config);
reporter.watchProcess("api");
const app = await buildApp({ config, db, realtime: "socket", reporter });
const shutdown = async (signal: string) => {
app.log.info({ signal }, "shutting down");
await app.close();
await db.$disconnect();
process.exit(0);
};
process.on("SIGTERM", () => void shutdown("SIGTERM"));
process.on("SIGINT", () => void shutdown("SIGINT"));
try {
await app.listen({ port: config.PORT, host: "0.0.0.0" });
} catch (err) {
app.log.error(err);
process.exit(1);
}