Some checks failed
Release Workflow / determine-release-type (push) Has been cancelled
Release Workflow / checks (push) Has been cancelled
Release Workflow / e2e-tests (push) Has been cancelled
Release Workflow / build-images (push) Has been cancelled
Release Workflow / publish-release (push) Has been cancelled
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { logger } from "./server/utils/logger";
|
|
import { shutdown } from "./server/modules/lifecycle/shutdown";
|
|
import { runCLI } from "./server/cli";
|
|
import { bootstrapApplication } from "./server/modules/lifecycle/bootstrap";
|
|
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);
|
|
}
|
|
|
|
await bootstrapApplication();
|
|
|
|
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);
|
|
}
|
|
});
|