-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.js
68 lines (52 loc) · 1.31 KB
/
application.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import BaseApplication from 'common/application';
import extend from 'lodash/object/extend';
import cluster from 'cluster';
import http from './http';
import emailer from './emailer';
import stripe from './stripe';
import APIBus from './bus';
import cronTasks from './cron-tasks';
class APIApplication extends BaseApplication {
/**
*/
intl = {
messages: require('common/translations/en')
}
/**
*/
initialize(next) {
this.logger.info('bt hosts: ', this.config.hosts);
this.logger.info('redis host: ', this.config.redis.host);
this.logger.info('directories: ', this.config.directories);
// fork it?
if (cluster.isMaster && this.config.numCores > 0) {
this.logger.info('fourk it %d times ✊', this.config.numCores);
for (var i = this.config.numCores; i--;) this.fork();
if (next) next();
return;
}
return super.initialize(next);
}
/**
*/
initializePlugins() {
this.bus = APIBus.create(this, this.bus);
super.initializePlugins();
if (this.debug !== true) {
this.use(http);
}
this.use(
emailer,
stripe,
cronTasks
);
}
/**
*/
fork() {
cluster.fork().once('exit', this.fork.bind(this));
}
}
/**
*/
module.exports = APIApplication;