27 lines
549 B
TypeScript
27 lines
549 B
TypeScript
import 'dotenv/config';
|
|
import { buildApp } from './app.js';
|
|
import { env } from './config/env.js';
|
|
|
|
async function main() {
|
|
const app = await buildApp();
|
|
|
|
try {
|
|
await app.listen({ port: env.PORT, host: env.HOST });
|
|
app.log.info({ port: env.PORT }, 'Server started');
|
|
} catch (err) {
|
|
app.log.error(err);
|
|
process.exit(1);
|
|
}
|
|
|
|
const shutdown = async () => {
|
|
app.log.info('Shutting down...');
|
|
await app.close();
|
|
process.exit(0);
|
|
};
|
|
|
|
process.on('SIGINT', shutdown);
|
|
process.on('SIGTERM', shutdown);
|
|
}
|
|
|
|
main();
|