forked from Reportr/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreportr.js
95 lines (83 loc) · 2.11 KB
/
reportr.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env node
var _ = require('underscore');
var path = require('path');
var engineer = require('engineer');
var cli = require('commander');
var pkg = require('../package.json');
// Modules
var modulesSection = {
'*': [
"./config",
"./logger",
"./database",
"./queue",
"./notifications",
"./tasks",
"./trackers",
"./tracker.chrome",
"./tracker.facebook",
"./tracker.foursquare",
"./tracker.twitter",
"./tracker.github",
"./tracker.runkeeper",
"./tracker.fitbit",
"./tracker.ping",
"./model.user",
"./model.event",
"./model.eventmodel",
],
'worker': [
"./worker.main"
],
'web': [
"./web.api",
"./web.api.auth",
"./web.api.data",
"./web.api.models",
"./web.api.events",
"./web.api.trackers",
"./web.main"
],
'all': [
"./web.api",
"./web.api.auth",
"./web.api.data",
"./web.api.models",
"./web.api.events",
"./web.api.trackers",
"./web.main",
"./worker.main"
]
};
cli
.command('run')
.description('Run reportr with mode <mode>.')
.action(function() {
var that = this;
if (this.mode == null) {
console.log("Define running mode with option -m (or --mode=<mode>)");
return;
}
if (modulesSection[this.mode] == null) {
console.log("Invalid mode for running Reportr");
return;
}
var modules = _.union(modulesSection["*"], modulesSection[this.mode]);
var app = new engineer.Application({
'paths': [
path.resolve(__dirname, '..', 'lib')
]
});
app.on("error", function(err) {
console.log("Error in the application:");
console.log(err.stack);
// Kill process
process.exit(1);
});
return app.load(modules).then(function() {
return Q(app);
});
});
cli.option('-m, --mode <web or worker>', 'Run mode for this process.');
cli.version(pkg.version).parse(process.argv);
if (!cli.args.length) cli.help();