Comparing version 1.2.4 to 1.3.0
@@ -6,2 +6,8 @@ 'use strict'; | ||
// exiting with parent process | ||
process.on('disconnect', function () { | ||
console.log('exiting with parent process'); | ||
process.exit(0); | ||
}); | ||
var readConfig = function(confPath) { | ||
@@ -8,0 +14,0 @@ var cfg = require(confPath); |
@@ -29,3 +29,3 @@ 'use strict'; | ||
if (this.reportInterval < 60000) { | ||
throw new Error("report interval should not less than 60s"); | ||
throw new Error('report interval should not less than 60s'); | ||
} | ||
@@ -39,3 +39,3 @@ this.config = config; | ||
CLOSED: 'closed', | ||
REGISTERING: 'registering', | ||
REGISTERING: 'registering' | ||
}; | ||
@@ -53,3 +53,3 @@ | ||
}); | ||
this.conn.on('message', function (data, flags) { | ||
this.conn.on('message', function (data) { | ||
that.onMessage(data); | ||
@@ -94,3 +94,3 @@ }); | ||
Agent.prototype.sendRegisterMessage = function () { | ||
debug("send register message"); | ||
debug('send register message'); | ||
var params = { | ||
@@ -157,3 +157,3 @@ version: AGENT_VERSION, | ||
if (signature !== this.signature(message)) { | ||
debug("签名错误,忽略。message id: %s", message.id); | ||
debug('签名错误,忽略。message id: %s', message.id); | ||
return; | ||
@@ -201,3 +201,3 @@ } | ||
Agent.prototype.sendHeartbeatMessage = function (id) { | ||
debug("send heartbeat message. id: %s", id); | ||
debug('send heartbeat message. id: %s', id); | ||
var params = {interval: this.heartbeatInterval}; | ||
@@ -215,3 +215,3 @@ var message = { | ||
Agent.prototype.sendResultMessage = function (id, err, stdout, stderr) { | ||
debug("send result message. id: %s", id); | ||
debug('send result message. id: %s', id); | ||
var params = {}; | ||
@@ -267,7 +267,8 @@ if (err) { | ||
// TODO: 太暴力了,需要个简单的词法分析来精确判断 | ||
if (command.indexOf("|") !== -1 || command.indexOf(">") !== -1 || command.indexOf("&") !== -1) { | ||
that.sendResultMessage(id, new Error("命令行包含非法字符")); | ||
if (command.indexOf('|') !== -1 || command.indexOf('>') !== -1 || | ||
command.indexOf('&') !== -1) { | ||
that.sendResultMessage(id, new Error('命令行包含非法字符')); | ||
return; | ||
} | ||
var parts = command.split(" "); | ||
var parts = command.split(' '); | ||
var cmd = parts[0]; | ||
@@ -280,3 +281,3 @@ var args = parts.slice(1); | ||
debug('no such file: %s', file); | ||
that.sendResultMessage(id, new Error("No such file")); | ||
that.sendResultMessage(id, new Error('No such file')); | ||
return; | ||
@@ -283,0 +284,0 @@ } |
@@ -50,4 +50,3 @@ 'use strict'; | ||
if (!stats.isFile()) { | ||
err = new Error(filepath + ' is not a file'); | ||
return callback(err); | ||
return callback(new Error(filepath + ' is not a file')); | ||
} | ||
@@ -108,3 +107,3 @@ | ||
if (!exports.logdir) { | ||
return callback(new Error("Not specific logdir in agentx config file")); | ||
return callback(new Error('Not specific logdir in agentx config file')); | ||
} | ||
@@ -111,0 +110,0 @@ |
'use strict'; | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var execFile = require('child_process').execFile; | ||
var helper = require('../utils'); | ||
@@ -13,15 +12,4 @@ var command = ''; | ||
var getVersion = function (callback) { | ||
fs.access(command, fs.X_OK, function (err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
execFile(command, function (err, stdout) { | ||
callback(err, stdout); | ||
}); | ||
}); | ||
}; | ||
exports.run = function (callback) { | ||
getVersion(function (err, stdout) { | ||
helper.execFile(command, function (err, stdout) { | ||
if (err) { | ||
@@ -40,2 +28,2 @@ return callback(err); | ||
exports.reportInterval = 24 * 60 * 60 * 1000; // 1day | ||
exports.reportInterval = 60 * 60 * 1000; // 1hour |
'use strict'; | ||
var os = require('os'); | ||
var fs = require('fs'); | ||
var crypto = require('crypto'); | ||
@@ -16,2 +17,11 @@ var execFile = require('child_process').execFile; | ||
exports.execFile = function (command, callback) { | ||
fs.access(command, fs.X_OK, function (err) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
execFile(command, callback); | ||
}); | ||
}; | ||
var uid = 1000; | ||
@@ -18,0 +28,0 @@ exports.uid = function () { |
{ | ||
"name": "agentx", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "agentx is powered by alinode", | ||
@@ -14,3 +14,3 @@ "scripts": { | ||
"dependencies": { | ||
"ws": "^0.8.0", | ||
"ws": "^0.8.1", | ||
"nounou": "1.0.1", | ||
@@ -22,6 +22,9 @@ "debug": "*", | ||
"devDependencies": { | ||
"coveralls": "^2.11.6", | ||
"expect.js": "*", | ||
"istanbul": "*", | ||
"mocha": "*" | ||
"mm": "^1.3.5", | ||
"mocha": "*", | ||
"rewire": "~2.5.1" | ||
} | ||
} |
@@ -6,2 +6,6 @@ AgentX | ||
- [![Build Status](https://travis-ci.org/aliyun-node/agentx.png?branch=master)](https://travis-ci.org/aliyun-node/agentx) | ||
- [![Dependencies Status](https://david-dm.org/aliyun-node/agentx.png)](https://david-dm.org/aliyun-node/agentx) | ||
- [![Coverage Status](https://coveralls.io/repos/aliyun-node/agentx/badge.png)](https://coveralls.io/r/aliyun-node/agentx) | ||
## Installation | ||
@@ -8,0 +12,0 @@ |
@@ -39,2 +39,6 @@ #!/usr/bin/env node | ||
}) | ||
.on('expectedExit', function (client, code, signal) { | ||
console.log('[%s] [%s], client %s died (code: %s, signal: %s)', Date(), | ||
process.pid, client.pid, code, signal); | ||
}) | ||
.on('unexpectedExit', function (client, code, signal) { | ||
@@ -41,0 +45,0 @@ var err = new Error(util.format('client %s died (code: %s, signal: %s)', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28727
20
899
46
1
6
Updatedws@^0.8.1