forked from Matthew-Smith/general-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.ts
35 lines (27 loc) · 894 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
35
import 'core-js';
import 'regenerator-runtime/runtime';
import './tracer';
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 })}`);
}
})();