forked from aliyun-node/agentx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.js
executable file
·44 lines (37 loc) · 1.07 KB
/
client.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
'use strict';
var path = require('path');
var argv = process.argv.slice(2);
// exiting with parent process
process.on('disconnect', function () {
console.log('exiting with parent process');
process.exit(0);
});
var readConfig = function(confPath) {
var cfg = require(confPath);
if (!cfg.server ||
!cfg.appid ||
!cfg.secret ||
!cfg.cmddir ||
!cfg.logdir ||
!cfg.heartbeatInterval ||
!cfg.reconnectDelay ||
!cfg.reportInterval) {
console.log('配置文件:');
console.log(JSON.stringify(cfg, null, 2));
console.log('请检查配置文件, 确保以下参数配置:');
console.log(' server, appid, secret, cmddir, logdir, heartbeatInterval, reconnectDelay, reportInterval');
process.send({type: 'suicide'});
process.exit(1);
}
return cfg;
};
process.on('uncaughtException', function (err) {
console.log(new Date());
console.log(err.message);
console.log(err.stack);
process.exit(-1);
});
var Agent = require('./lib/agent');
var confPath = path.resolve(argv[0]);
var agent = new Agent(readConfig(confPath));
agent.run();