This commit is contained in:
25
server/src/index.ts
Normal file
25
server/src/index.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { buildApp } from './app.js';
|
||||
import { config } from './config.js';
|
||||
import { closePool } from './db/pool.js';
|
||||
|
||||
const app = buildApp();
|
||||
|
||||
async function start() {
|
||||
try {
|
||||
await app.listen({ host: '0.0.0.0', port: config.API_PORT });
|
||||
} catch (error) {
|
||||
app.log.error(error);
|
||||
await closePool();
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
for (const signal of ['SIGINT', 'SIGTERM']) {
|
||||
process.once(signal, () => {
|
||||
app.close()
|
||||
.then(closePool)
|
||||
.finally(() => process.exit(0));
|
||||
});
|
||||
}
|
||||
|
||||
void start();
|
||||
Reference in New Issue
Block a user