forked from allcount/allcountjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
allcount.js
31 lines (25 loc) · 990 Bytes
/
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
#!/usr/bin/env node
var argv = require('minimist')(process.argv.slice(2));
var injection = require('./services/injection');
var port = argv.port || process.env.PORT || 9080;
var gitUrl = argv.git || process.env.GIT_URL;
var dbUrl = argv.db || process.env.DB_URL;
if (!gitUrl || !dbUrl) {
console.log('Usage: allcountjs --git <Application 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);
injection.installModulesFromPackageJson("package.json");
var server = injection.inject('allcountServerStartup');
server.startup(function (errors) {
if (errors) {
throw new Error(errors.join('\n'));
}
});