-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentry.js
52 lines (37 loc) · 1.03 KB
/
entry.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';
const rfr = require('rfr');
const fs = require('fs');
const logger = rfr('lib/logger');
logger.info('Starting application...');
rfr('lib/config-wrapper').read();
if(typeof global.config == 'undefined') {
return;
}
const connections = {
MongoDB: false,
Redis: false
};
rfr('lib/redis');
Redis.on('connected', () => {
logger.debug('Connected to Redis');
connections.Redis = true;
rfr('lib/mongo');
MongoDB.on('connected', () => {
logger.debug('Connected to MongoDB');
connections.MongoDB = true;
rfr('resizer').startup();
if(config.healthcheck && config.healthcheck.enable) {
rfr('web');
} else {
logger.warn('Not enabling http healthcheck');
}
});
});
setTimeout(() => {
if(!connections.MongoDB || !connections.Redis) {
logger.error('Connection timeout for databases. Quitting..');
global.Redis = false;
global.MongoDB = false;
setTimeout(() => process.exit(1), 150);
}
}, 5000);