-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.js
52 lines (47 loc) · 1.38 KB
/
config.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
41
42
43
44
45
46
47
48
49
50
51
52
'use strict'
// Set up config variables
var config = module.exports = {
name: 'RF433-to-REST',
version: '1.0.0',
env: process.env.NODE_ENV || 'development',
var_dir: process.env.VAR_DIR || '/tmp',
port: process.env.PORT || 8000,
base_url: process.env.BASE_URL || 'http://localhost:8000',
receiver_location: "living"
}
// Start logging services
const winston = require('winston');
global.logger = winston.loggers.add('devLog', {
console: {
silent: (config.env=="development")?false:true,
level: 'debug',
colorize: true,
// label: 'devLog',
handleExceptions: true, //catches uncaught exceptions
humanReadableUnhandledException: true
},
File: {
// label: 'devLog',
level: 'debug',
// colorize: true,
handleExceptions: true,
filename: config.var_dir+'/debug.log',
maxsize: 1000000,
tailable:true,
maxFiles:7
}
});
function exitHandler(options, err) {
if (options.cleanup){
// This section gets executed after process.exit()
logger.info('Service stopping');
}
if (options.exit) process.exit();
}
//do something when app is closing
process.on('exit', exitHandler.bind(null,{cleanup:true}));
//catches ctrl+c event
process.on('SIGINT', exitHandler.bind(null, {exit:true}));
//catches kill event
process.on('SIGTERM', exitHandler.bind(null, {exit:true}));
logger.info('Service started');