forked from governify/collector-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (30 loc) · 1.13 KB
/
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
'use strict';
// if (process.env.NEW_RELIC_APP_NAME && process.env.NEW_RELIC_LICENSE_KEY) require('newrelic');
const governify = require('governify-commons');
const logger = governify.getLogger().tag('index');
const server = require('./server');
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'production';
if (env === 'e2e') {
governify.init().then((commonsMiddleware) => {
require('./tests/nockController').instantiateMockups(env).then(() => {
server.deploy(env, commonsMiddleware).catch(logger.error);
}).catch(logger.error);
});
} else {
governify.init().then((commonsMiddleware) => {
server.deploy(env, commonsMiddleware).catch(logger.error);
});
}
// quit on ctrl-c when running docker in terminal
process.on('SIGINT', function onSigint () {
logger.info('Got SIGINT (aka ctrl-c in docker). Graceful shutdown ', new Date().toISOString());
shutdown();
});
// quit properly on docker stop
process.on('SIGTERM', function onSigterm () {
logger.info('Got SIGTERM (docker container stop). Graceful shutdown ', new Date().toISOString());
shutdown();
});
const shutdown = () => {
server.undeploy();
};