-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (51 loc) · 1.56 KB
/
main.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
var getopt = require('posix-getopt');
var restify = require('restify');
var ti = require('./server.js');
var sysConfig = require('./config/SystemConfig.js')
var serverLogger = require('./util/ServerLogger.js');
var logger = serverLogger.createLogger('main.js');
var encrypt = require('./util/Encrypt.js');
///--- Globals
var NAME = 'fhu';
// In true UNIX fashion, debug messages go to stderr, and audit records go
function parseOptions() {
var option;
var opts = {}
var parser = new getopt.BasicParser(':h:p:(port)', process.argv);
while ((option = parser.getopt()) !== undefined) {
switch (option.option) {
case 'p':
opts.port = parseInt(option.optarg, 10);
break;
case 'h':
usage();
break;
default:
usage('invalid option: ' + option.option);
break;
}
}
return (opts);
}
function usage(msg) {
if (msg)
console.error(msg);
var str = 'usage: ' +
NAME +
'[-p port] [-h]';
console.error(str);
process.exit(msg ? 1 : 0);
}
(function main() {
var opt=parseOptions();
var server = ti.createServer();
var adminServer = ti.createServer();
server.listen((opt.port?opt.port:9001), function onListening() {
server.get('/',restify.plugins.serveStatic({
directory: './public/docs',
default: 'index.html',
maxAge: 0
}));
logger.info('LOG-API server has been started ,listening at %s', server.url);
});
})();