forked from allcount/allcountjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allcount.js
executable file
·39 lines (33 loc) · 1.19 KB
/
allcount.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
#!/usr/bin/env node
var argv = require('minimist')(process.argv.slice(2));
var injection = require('./services/injection');
var _ = require('lodash');
var fs = require('fs');
var port = argv.port || process.env.PORT || 9080;
var gitUrl = argv.app || process.env.APP || argv.git || process.env.GIT_URL;
var dbUrl = argv.db || process.env.DB_URL;
if (!gitUrl || !dbUrl) {
console.log('Usage: allcountjs --app <Path to application\'s dir or Git URL> --db <Application MongoDB URL> -port [Application HTTP port]');
process.exit(0);
}
require('./allcount-server.js');
injection.bindFactory('port', port);
injection.bindFactory('dbUrl', dbUrl);
if (dbUrl.indexOf('postgres') !== -1) {
injection.bindFactory('storageDriver', require('./services/sql-storage-driver'));
injection.bindFactory('dbClient', 'pg');
}
injection.bindFactory('gitRepoUrl', gitUrl);
if (fs.existsSync("package.json")) {
injection.installModulesFromPackageJson("package.json");
}
var server = injection.inject('allcountServerStartup');
server.startup(function (errors) {
if (errors) {
if (_.isArray(errors)) {
throw new Error(errors.join('\n'));
} else {
throw errors;
}
}
});