-
Notifications
You must be signed in to change notification settings - Fork 16
/
start.ts
34 lines (26 loc) · 875 Bytes
/
start.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import 'core-js';
import 'regenerator-runtime/runtime';
import { ServiceManager } from './backend';
import config from './config';
import log from './logger';
import Server from './server';
(async () => {
const serviceManager = new ServiceManager(config);
const server = new Server(serviceManager, config);
// Graceful shutdown from SIGTERM
process.on('SIGTERM', async () => {
log.warn('[app] [http] SIGTERM received stopping server');
await server.stop();
log.warn('[app] exiting');
// eslint-disable-next-line no-process-exit
process.exit(0);
});
process.on('unhandledRejection', (rejection, promise) => {
log.error(`[app] unhandled rejection ${log.vars({ rejection, promise })}`);
});
try {
await server.start();
} catch (error) {
log.error(`[app] [http] failed to start server ${log.vars({ error })}`);
}
})();