-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
40 lines (34 loc) · 933 Bytes
/
index.js
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
const https = require('https');
const ws = require('nodejs-websocket');
const app = require('./app');
const wsApp = require('./wsApp');
const config = require('./config');
const logger = require('./services/logger');
config
.then(config => {
const listen = https.createServer({
key: config.KEY,
cert: config.CERT,
requestCert: false,
rejectUnauthorized: false,
}, app).listen(config.PORT);
ws.createServer({
secure: true,
key: config.KEY,
cert: config.CERT,
}, wsApp).listen(config.WEBSOCKET_PORT);
logger.info(`Application started on ports: http - ${config.PORT}, ws - ${config.WEBSOCKET_PORT}`);
process.on('SIGTERM', () => {
listen.close();
});
process.on('SIGINT', () => {
listen.close();
});
listen.on('close', () => {
process.exit();
});
})
.catch(error => {
logger.error(error);
process.exit(1);
});