Skip to content

Commit

Permalink
fix jshint error
Browse files Browse the repository at this point in the history
  • Loading branch information
hzxuzhonghu committed Nov 3, 2015
1 parent 87c0d41 commit a46fb5f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
3 changes: 2 additions & 1 deletion gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ module.exports = function(grunt) {
jshint: {
all: ['lib/*'],
options: {
node: true
node: true,
sub: true
}
}
});
Expand Down
24 changes: 12 additions & 12 deletions lib/monitors/common/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ var util = require('util');
Command.init = function(client, data) {
logger.debug('server: %s receive command, with data: %j', client.app.serverId, data);
if(!data) {
logger.warn('server: %s command data is null.', client.app.serverId);
return;
}
data = JSON.parse(data);
switch(data.command) {
logger.warn('server: %s command data is null.', client.app.serverId);
return;
}
data = JSON.parse(data);
switch(data.command) {
case 'stop':
stop(client);
break;
Expand Down Expand Up @@ -94,7 +94,7 @@ var set = function(client, msg) {
var get = function(client, msg) {
var value = client.app.get(msg.param);
if (!checkJSON(value)) {
value = 'object';
value = 'object';
}

logger.info('get %s the value is %s in server %s', msg.param, value, client.app.serverId);
Expand Down Expand Up @@ -147,7 +147,7 @@ var exec = function(client, msg) {
}
} catch (e) {
logger.error('exec %s in server %s with err %s', msg.script, client.app.serverId, e.toString());
client.sendCommandResult(e.toString())
client.sendCommandResult(e.toString());
}
};

Expand Down Expand Up @@ -183,7 +183,7 @@ var show = function(client, msg) {
break;
}
client.sendCommandResult(JSON.stringify(result));
}
};

var getConnectionInfo = function(client) {
var connectionInfo = {};
Expand All @@ -204,7 +204,7 @@ var getProxyInfo = function(client) {
var proxies = __proxy__.client.proxies.user;
var server = client.app.getServerById(client.app.serverId);
if (!server) {
cb('no server with this id ' + client.app.serverId);
logger.error('no server with this id ' + client.app.serverId);
} else {
var type = server['serverType'];
var tmp = proxies[type];
Expand Down Expand Up @@ -232,7 +232,7 @@ var getHandlerInfo = function(client) {
var handles = __server__.server.handlerService.handlers;
var server = client.app.getServerById(client.app.serverId);
if (!server) {
cb('no server with this id ' + client.app.serverId);
logger.error('no server with this id ' + client.app.serverId);
} else {
var type = server['serverType'];
var tmp = handles;
Expand All @@ -258,7 +258,7 @@ var getComponentInfo = function(client) {
var res = {};
for (var key in _components) {
var name = getComponentName(key);
res[name] = clone(name, client.app.get(name + 'Config'))
res[name] = clone(name, client.app.get(name + 'Config'));
}
return {componentInfo: res};
};
Expand Down Expand Up @@ -329,4 +329,4 @@ function checkJSON(obj) {
return false;
}
return true;
};
}
13 changes: 7 additions & 6 deletions lib/monitors/zookeepermonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ var getProxyInfo = function(zk) {
var proxies = __proxy__.client.proxies.user;
var server = zk.app.getServerById(zk.app.serverId);
if (!server) {
cb('no server with this id ' + zk.app.serverId);
logger.error('no server with this id ' + zk.app.serverId);
} else {
var type = server['serverType'];
var tmp = proxies[type];
Expand Down Expand Up @@ -237,7 +237,7 @@ var getHandlerInfo = function(zk) {
var handles = __server__.server.handlerService.handlers;
var server = zk.app.getServerById(zk.app.serverId);
if (!server) {
cb('no server with this id ' + zk.app.serverId);
logger.error('no server with this id ' + zk.app.serverId);
} else {
var type = server['serverType'];
var tmp = handles;
Expand All @@ -263,7 +263,7 @@ var getComponentInfo = function(zk) {
var res = {};
for (var key in _components) {
var name = getComponentName(key);
res[name] = clone(name, zk.app.get(name + 'Config'))
res[name] = clone(name, zk.app.get(name + 'Config'));
}
return res;
};
Expand Down Expand Up @@ -308,15 +308,15 @@ function clone(param, obj) {
// return 'no ' + param + 'Config info';
}
return result;
};
}

function getComponentName(c) {
var t = c.match(/^__(\w+)__$/);
if (t) {
t = t[1];
}
return t;
};
}

function checkJSON(obj) {
if (!obj) {
Expand All @@ -328,7 +328,7 @@ function checkJSON(obj) {
return false;
}
return true;
};
}

var createAllNode = function(zk, value, mode, cb) {
async.series([
Expand Down Expand Up @@ -483,3 +483,4 @@ var reconnect = function(self) {
}
);
};

1 change: 1 addition & 0 deletions lib/pomelo.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Pomelo.monitors.__defineGetter__('redismonitor', load.bind(null, './monitors/red
*/
Pomelo.createApp = function (opts) {
var app = application;
console.log('--------',application);
app.init(opts);
Pomelo.app = app;
return app;
Expand Down
8 changes: 4 additions & 4 deletions test/modules/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ describe('cmd test', function() {
}
};

var data = {command: 1};
var data = {command: 'stop'};
commander.init(client, JSON.stringify(data));
flag.should.eql(true);
/*
data = {command: 2};
commander.init(client, JSON.stringify(data));
flag.should.eql(true);
*/
data = {command: 3, cron: {
data = {command: 'addCron', cron: {
type: 'chat',
id: 'chat-server-1'
}
};
commander.init(client, JSON.stringify(data));
rs.length.should.eql(1);

data = {command: 4, cron: {
data = {command: 'removeCron', cron: {
type: 'chat',
id: 'chat-server-1'
}
};
commander.init(client, JSON.stringify(data));
rs.length.should.eql(1);

data = {command: 5, blacklist: ['127.0.0.1'] };
data = {command: 'blacklist', blacklist: ['127.0.0.1'] };
commander.init(client, JSON.stringify(data));
client.app.components.__connector__.blacklist.length.should.eql(1);
});
Expand Down

0 comments on commit a46fb5f

Please sign in to comment.