-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (22 loc) · 916 Bytes
/
Copy pathindex.js
File metadata and controls
30 lines (22 loc) · 916 Bytes
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
'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('initialization');
const server = require('./server');
const env = process.env.NODE_ENV ? process.env.NODE_ENV : 'production';
governify.init().then((commonsMiddleware) => {
server.deploy(env, commonsMiddleware).catch(err => { logger.error(err); });
});
// 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();
};