-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (43 loc) · 1.23 KB
/
Copy pathindex.js
File metadata and controls
52 lines (43 loc) · 1.23 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
// require new relic at the top only in production environment
if (process.env.NODE_ENV === 'production') {
require('newrelic')
}
const config = require('config')
const server = require('./server')
const gracefulStopServer = function () {
// Wait 10 secs for existing connection to close and then exit.
server.stop({timeout: 10 * 1000}, () => {
process.exit(0)
})
}
process.on('uncaughtException', err => {
console.log(err);
process.exit(1)
})
process.on('unhandledRejection', (reason, promise) => {
console.log(reason);
process.exit(1)
})
process.on('SIGINT', gracefulStopServer)
process.on('SIGTERM', gracefulStopServer)
/**
* Starts the server
* @returns {Promise.<void>}
*/
const startServer = async function () {
try {
// add things here before the app starts, like database connection check etc
console.log("Hello, establishing connection with the server !!");
await server.start((err) => {
if (err) {
console.log("error server connect", err)
}
console.log('Server running at:', server.info.uri);
});
} catch (error) {
console.log(error);
process.exit(1);
}
}
startServer();