mirror of
https://github.com/nicotsx/zerobyte.git
synced 2026-02-19 23:34:53 -05:00
* refactor: add nitro bootstrap plugin to ensure app is started before first call * refactor(bootstrap): avoid duplicate event firing * refactor: extract common setup in initModule function * refactor: remove proxy pattern for db and auth Since we migrated away from rr this is not needed anymore as the bundler correctly split chunks
47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { logger } from "./server/utils/logger";
|
|
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
|
import { runCLI } from "./server/cli";
|
|
import {
|
|
createStartHandler,
|
|
defaultStreamHandler,
|
|
defineHandlerCallback,
|
|
} from "@tanstack/react-start/server";
|
|
import { createServerEntry } from "@tanstack/react-start/server-entry";
|
|
|
|
const cliRun = await runCLI(Bun.argv);
|
|
if (cliRun) {
|
|
process.exit(0);
|
|
}
|
|
|
|
const customHandler = defineHandlerCallback((ctx) => {
|
|
return defaultStreamHandler(ctx);
|
|
});
|
|
|
|
const fetch = createStartHandler(customHandler);
|
|
|
|
export default createServerEntry({
|
|
fetch,
|
|
});
|
|
|
|
process.on("SIGTERM", async () => {
|
|
logger.info("SIGTERM received, starting graceful shutdown...");
|
|
try {
|
|
await shutdown();
|
|
} catch (err) {
|
|
logger.error("Error during shutdown", err);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
});
|
|
|
|
process.on("SIGINT", async () => {
|
|
logger.info("SIGINT received, starting graceful shutdown...");
|
|
try {
|
|
await shutdown();
|
|
} catch (err) {
|
|
logger.error("Error during shutdown", err);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
});
|