forked from eggjs/egg-alinode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent.js
34 lines (30 loc) · 953 Bytes
/
agent.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
'use strict';
const assert = require('assert');
const AlinodeAgent = require('agentx');
const homedir = require('node-homedir');
const fs = require('fs');
const path = require('path');
module.exports = agent => {
const config = agent.config.alinode;
if (!config.enable) {
agent.coreLogger.info('[egg-alinode] disable');
return;
}
assert(config.appid, 'config.alinode.appid required');
assert(config.secret, 'config.alinode.secret required');
const nodepathFile = path.join(homedir(), '.nodepath');
const nodeBin = path.dirname(process.execPath);
fs.writeFileSync(nodepathFile, nodeBin);
config.logger = agent.coreLogger;
config.libMode = true;
new AlinodeAgent(config).run();
agent.coreLogger.info('[egg-alinode] alinode agentx started, node versions: %j, update %s with %j, config: %j',
process.versions,
nodepathFile,
nodeBin,
{
server: config.server,
appid: config.appid,
}
);
};