forked from marklogic-community/demo-cat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.js
executable file
·39 lines (32 loc) · 1.04 KB
/
startup.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
/*
* Script to run from forever to start the server
*/
/* global console */
/* global process */
/* global require */
(function () {
'use strict';
console.log('Starting node server..');
var args = {};
process.argv.forEach(function(arg, index, array) {
//console.log('argv['+index+']=' + arg);
if (arg.match(/^--([^=]+)=(.*)$/)) {
var key = arg.replace(/^--([^=]+)=(.*)$/, '$1');
var val = arg.replace(/^--([^=]+)=(.*)$/, '$2');
args[key] = val;
//console.log(key + '=' + val);
}
});
var options = {
serverScript: args['server-script'] || './server.js',
appPort: args['app-port'] || 9040,
mlHost: args['ml-host'] || 'localhost',
mlPort: args['ml-port'] || 8040
};
console.log('server-script: ' + options.serverScript);
console.log('app-port: ' + options.appPort);
console.log('ml-host: ' + options.mlHost);
console.log('ml-port: ' + options.mlPort);
var server = require(options.serverScript).buildExpress(options);
server.listen(options.appPort);
})();