-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.ts
40 lines (35 loc) · 1.04 KB
/
index.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
36
37
38
39
40
import * as debug from 'debug';
import * as express from 'express';
import './apm';
import { initAPI } from './initialize';
import { Websockets } from './websockets';
// Inicializa express
const app = express();
initAPI(app);
// Inicia el servidor HTTP
const port = 3002;
const server = app.listen(3002, () => debug('andes')('listening on port %s', port));
server.keepAliveTimeout = 65 * 1000;
server.headersTimeout = 61 * 1000;
// Inicializa Websockets
Websockets.initialize(server);
// Muestra mensaje y línea de un error dentro de una promise ;-)
process.on('unhandledRejection', r => debug('andes')(r));
process.on('uncaughtException', r => debug('andes')(r));
/**
* Gracefull shutdown
*/
process.on('SIGINT', () => {
debug('andes')('gracefull shutdown');
server.close(() => {
setTimeout(
() => {
const { Connections } = require('./connections');
Connections.main.close().then(() => {
process.exit();
});
}
, 500
);
});
});