Skip to content
This repository was archived by the owner on Sep 25, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/pomelo
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var fs = require('fs'),
exec = require('child_process').exec,
spawn = require('child_process').spawn,
version = require('../package.json').version,
adminClient = require('pomelo-admin').adminClient,
adminClient = require('pomelo-admin-js').adminClient,
constants = require('../lib/util/constants'),
program = require('commander');

Expand Down
4 changes: 2 additions & 2 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Application.require = function(ph) {

/**
* Configure logger with {$base}/config/log4js.json
*
*
* @param {Object} logger pomelo-logger instance without configuration
*
* @memberOf Application
Expand Down Expand Up @@ -364,7 +364,7 @@ Application.beforeStopHook = function(fun) {
utils.invokeCallback(cb, new Error('application has already start.'));
return;
}

var self = this;
appUtil.startByType(self, function() {
appUtil.loadDefaultComponents(self);
Expand Down
4 changes: 2 additions & 2 deletions lib/common/manager/appManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ manager.transaction = function(name, conditions, handlers, retry) {

var flag = true;
var times = retry;

// do retry if failed util retry times
async.whilst(
function() {
Expand Down Expand Up @@ -110,4 +110,4 @@ manager.transaction = function(name, conditions, handlers, retry) {
});
}
});
};
};
4 changes: 2 additions & 2 deletions lib/common/remote/backend/msgRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ Remote.prototype.forwardMessage2 = function(route, body, aesPassword, compressGz
if(err) {
return cb(err);
}

server.handle(msg, backendSession, function(err, resp, opts) {
utils.invokeCallback(cb, err, resp, opts);
});
});
};
};
4 changes: 2 additions & 2 deletions lib/common/remote/frontend/channelRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Remote.prototype.pushMessage = function(route, msg, uids, opts, cb) {
utils.invokeCallback(cb, new Error('can not send empty message.'));
return;
}

var connector = this.app.components.__connector__;

var sessionService = this.app.get('sessionService');
Expand All @@ -55,7 +55,7 @@ Remote.prototype.pushMessage = function(route, msg, uids, opts, cb) {
*
* @param {String} route route string
* @param {Object} msg message
* @param {Boolean} opts broadcast options.
* @param {Boolean} opts broadcast options.
* @param {Function} cb callback function
*/
Remote.prototype.broadcast = function(route, msg, opts, cb) {
Expand Down
6 changes: 3 additions & 3 deletions lib/common/service/channelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ChannelService.prototype.destroyChannel = function(name) {
* @param {String} route message route
* @param {Object} msg message that would be sent to client
* @param {Array} uids the receiver info list, [{uid: userId, sid: frontendServerId}]
* @param {Object} opts user-defined push options, optional
* @param {Object} opts user-defined push options, optional
* @param {Function} cb cb(err)
* @memberOf ChannelService
*/
Expand Down Expand Up @@ -183,7 +183,7 @@ ChannelService.prototype.broadcast = function(stype, route, msg, opts, cb) {

opts = {type: 'broadcast', userOptions: opts || {}};

// for compatiblity
// for compatiblity
opts.isBroadcast = true;
if(opts.userOptions) {
opts.binded = opts.userOptions.binded;
Expand Down Expand Up @@ -424,7 +424,7 @@ var sendMessageByGroup = function(channelService, route, msg, groups, opts, cb)
opts = {type: 'push', userOptions: opts || {}};
// for compatiblity
opts.isPush = true;

var sendMessage = function(sid) {
return (function() {
if(sid === app.serverId) {
Expand Down
2 changes: 1 addition & 1 deletion lib/common/service/handlerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ var getResp = function(args) {
}

return r;
}
}
8 changes: 4 additions & 4 deletions lib/common/service/sessionService.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ module.exports = SessionService;
/**
* Create and return internal session.
*
* @param {Integer} sid uniqe id for the internal session
* @param {String} frontendId frontend server in which the internal session is created
* @param {Object} socket the underlying socket would be held by the internal session
* @param {Integer} sid uniqe id for the internal session
* @param {String} frontendId frontend server in which the internal session is created
* @param {Object} socket the underlying socket would be held by the internal session
*
* @return {Session}
*
Expand Down Expand Up @@ -425,7 +425,7 @@ var send = function(service, session, msg) {
* user id after the client passes the identification.
*
* Session is created in frontend server and should not be accessed in handler.
* There is a proxy class called BackendSession in backend servers and FrontendSession
* There is a proxy class called BackendSession in backend servers and FrontendSession
* in frontend servers.
*/
var Session = function(sid, frontendId, socket, service) {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/protobuf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var Component = function(app, opts) {
this.serverProtos = {};
this.clientProtos = {};
this.version = "";

var env = app.get(Constants.RESERVED.ENV);
var originServerPath = path.join(app.getBase(), Constants.FILEPATH.SERVER_PROTOS);
var presentServerPath = path.join(Constants.FILEPATH.CONFIG_DIR, env, path.basename(Constants.FILEPATH.SERVER_PROTOS));
Expand Down
2 changes: 1 addition & 1 deletion lib/components/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pro.start = function(cb) {

if(!!rpcBefores) {
this.client.before(rpcBefores);
}
}
if(!!rpcAfters) {
this.client.after(rpcAfters);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/components/pushScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var getScheduler = function(pushSchedulerComp, app, opts) {
});
pushSchedulerComp.isSelectable = true;
pushSchedulerComp.selector = opts.selector;
return res;
return res;
}

return scheduler;
Expand Down
2 changes: 1 addition & 1 deletion lib/connectors/common/coder.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ var encodeBody = function(server, route, msgBody) {
module.exports = {
encode: encode,
decode: decode
};
};
4 changes: 2 additions & 2 deletions lib/connectors/hybrid/tcpsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Socket.prototype.close = function() {
if(!!this.closeMethod && this.closeMethod === 'end') {
this._socket.end();
} else {
try {
this._socket.destroy();
try {
this._socket.destroy();
} catch (e) {
logger.error('socket close with destroy error: %j', e.stack);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/connectors/hybridsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,4 @@ Socket.prototype.disconnect = function() {
this.state = ST_CLOSED;
this.socket.emit('close');
this.socket.close();
};
};
10 changes: 5 additions & 5 deletions lib/connectors/mqttconnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,22 @@ Connector.prototype.start = function(cb) {
client.on('error', function(err) {
client.stream.destroy();
});

client.on('close', function() {
client.stream.destroy();
});

client.on('disconnect', function(packet) {
client.stream.destroy();
});

if(self.opts.disconnectOnTimeout) {
var timeout = self.opts.timeout * 1000 || constants.TIME.DEFAULT_MQTT_HEARTBEAT_TIMEOUT;
client.stream.setTimeout(timeout,function() {
client.emit('close');
});
}

client.on('connect', function(packet) {
client.connack({returnCode: 0});
var mqttsocket = new MQTTSocket(curId++, client, self.adaptor);
Expand Down Expand Up @@ -96,4 +96,4 @@ Connector.prototype.encode = function(reqId, route, msgBody) {

Connector.prototype.close = function() {
this.mqttServer.close();
};
};
4 changes: 2 additions & 2 deletions lib/connectors/udpsocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var ST_CLOSED = 3;

var Socket = function(id, socket, peer) {
EventEmitter.call(this);

this.id = id;
this.socket = socket;
this.peer = peer;
Expand Down Expand Up @@ -97,4 +97,4 @@ Socket.prototype.disconnect = function() {
}
this.state = ST_CLOSED;
this.emit('disconnect', 'the connection is disconnected.');
};
};
2 changes: 1 addition & 1 deletion lib/filters/handler/toobusy.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Filter.prototype.before = function(msg, session, next) {
} else {
next();
}
};
};
2 changes: 1 addition & 1 deletion lib/filters/rpc/rpcLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function() {
};

var Filter = function () {
};
};

Filter.prototype.name = 'rpcLog';

Expand Down
8 changes: 4 additions & 4 deletions lib/master/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var starter = require('./starter');
var logger = require('pomelo-logger').getLogger('pomelo', __filename);
var crashLogger = require('pomelo-logger').getLogger('crash-log', __filename);
var adminLogger = require('pomelo-logger').getLogger('admin-log', __filename);
var admin = require('pomelo-admin');
var admin = require('pomelo-admin-js');
var util = require('util');
var utils = require('../util/utils');
var moduleUtil = require('../util/moduleUtil');
Expand All @@ -14,7 +14,7 @@ var Server = function(app, opts) {
this.registered = {};
this.modules = [];
opts = opts || {};

opts.port = this.masterInfo.port;
opts.env = this.app.get(Constants.RESERVED.ENV);
this.closeWatcher = opts.closeWatcher;
Expand Down Expand Up @@ -45,14 +45,14 @@ Server.prototype.start = function(cb) {
utils.invokeCallback(cb);
});
});

this.masterConsole.on('error', function(err) {
if(!!err) {
logger.error('masterConsole encounters with error: ' + err.stack);
return;
}
});

this.masterConsole.on('reconnect', function(info){
self.app.addServers([info]);
});
Expand Down
6 changes: 5 additions & 1 deletion lib/master/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ starter.run = function(app, server, cb) {
}
starter.localrun(process.execPath, null, options, cb);
} else {
cmd = util.format('cd "%s" && "%s"', app.getBase(), process.execPath);
if(os.platform() === Constants.PLATFORM.WIN) {
cmd = util.format('cd /d "%s" && "%s"', app.getBase(), process.execPath);
} else {
cmd = util.format('cd "%s" && "%s"', app.getBase(), process.execPath);
}
var arg = server.args;
if (arg !== undefined) {
cmd += arg;
Expand Down
2 changes: 1 addition & 1 deletion lib/master/watchdog.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ Watchdog.prototype.notify = function(msg) {
requests[id] = 0;
moduleRequest(this, id);
}
};
};
11 changes: 8 additions & 3 deletions lib/modules/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var utils = require('../util/utils');
var Constants = require('../util/constants');
var starter = require('../master/starter');
var exec = require('child_process').exec;
var os = require('os');

module.exports = function(opts) {
return new Module(opts);
Expand Down Expand Up @@ -194,7 +195,7 @@ var restart = function(app, agent, msg, cb) {
for(var key in servers) {
serverIds.push(key);
}
}
}
var count = serverIds.length;
var latch = countDownLatch.createCountDownLatch(count, {timeout: Constants.TIME.TIME_WAIT_COUNTDOWN}, function() {
if(!successFlag) {
Expand Down Expand Up @@ -290,7 +291,7 @@ var checkPort = function(server, cb) {

var p = server.port || server.clientPort;
var host = server.host;
var cmd = 'netstat -tln | grep ';
var cmd = os.type() === 'Windows_NT' ? 'netstat -ano | findStr :' : 'netstat -tln | grep ';
if (!utils.isLocal(host)) {
cmd = 'ssh ' + host + ' ' + cmd;
}
Expand Down Expand Up @@ -325,6 +326,10 @@ var parseArgs = function(msg, info, cb) {
info[key] = 1;
}
rs[pairs[0]] = pairs[1];
//Extended memory limit
if(pairs[1] === '--max-old-space-size'){
rs[pairs[0]]+= '='+pairs[2];
}
}
return rs;
};
Expand Down Expand Up @@ -461,4 +466,4 @@ var ClusterInfo = {
host: 0,
port: 0,
clusterCount: 0
};
};
2 changes: 1 addition & 1 deletion lib/modules/masterwatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ var masterMethods = {
'unsubscribe': unsubscribe,
'query': query,
'record': record
};
};
4 changes: 2 additions & 2 deletions lib/monitor/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Load and start monitor client.
*/
var logger = require('pomelo-logger').getLogger('pomelo', __filename);
var admin = require('pomelo-admin');
var admin = require('pomelo-admin-js');
var moduleUtil = require('../util/moduleUtil');
var utils = require('../util/utils');
var Constants = require('../util/constants');
Expand Down Expand Up @@ -81,4 +81,4 @@ Monitor.prototype.reconnect = function(masterInfo) {
logger.info('restart modules for server : %j finish.', self.app.serverId);
});
});
};
};
Loading