krona-staff/src/server.ts
Ochenstarik 3464998168
Some checks are pending
ci / verify (push) Waiting to run
feat: add secure attendance portal and payroll foundation
2026-09-24 15:59:38 +07:00

31 lines
848 B
TypeScript

import { buildApp } from './app.js';
import { loadConfig } from './config.js';
const config = loadConfig();
const app = await buildApp({ config });
let shuttingDown = false;
const shutdown = (signal: string) => {
if (shuttingDown) return;
shuttingDown = true;
const timeout = setTimeout(() => {
app.log.error({ signal }, 'graceful shutdown timed out');
process.exit(1);
}, 10_000);
timeout.unref();
void app
.close()
.then(() => {
clearTimeout(timeout);
process.exit(0);
})
.catch((error: unknown) => {
clearTimeout(timeout);
app.log.error({ err: error, signal }, 'graceful shutdown failed');
process.exit(1);
});
};
process.on('SIGTERM', () => shutdown('SIGTERM'));
process.on('SIGINT', () => shutdown('SIGINT'));
await app.listen({ host: config.HOST, port: config.PORT });