Permalink
Browse files

Merge "Merge branch '0.3.x' of ssh://pomelo.163.com:29418/pomelo into…

… 0.3.x"
  • Loading branch information...
Charlie Edward Gerrit Code Review
Charlie Edward authored and Gerrit Code Review committed Jan 22, 2013
2 parents 75ed29a + 4fd1f61 commit baa584517fc9a860fd80bf5967f62a0d693e4fbe
Showing with 2,747 additions and 882 deletions.
  1. +4 −1 .jshintrc
  2. +15 −3 Makefile
  3. +35 −13 bin/pomelo
  4. +3 −1 index.js
  5. +229 −222 lib/application.js
  6. +20 −19 lib/common/service/channelService.js
  7. +4 −2 lib/common/service/connectionService.js
  8. +16 −3 lib/components/connector.js
  9. +75 −34 lib/components/proxy.js
  10. +2 −2 lib/components/remote.js
  11. +77 −0 lib/connectors/hybi/switcher.js
  12. +56 −0 lib/connectors/hybi/tcpprocessor.js
  13. +173 −0 lib/connectors/hybi/tcpsocket.js
  14. +52 −0 lib/connectors/hybi/wsprocessor.js
  15. +41 −0 lib/connectors/hybiconnector.js
  16. +56 −0 lib/connectors/hybisocket.js
  17. +4 −0 lib/connectors/sioconnector.js
  18. +45 −31 lib/master/master.js
  19. +33 −30 lib/master/starter.js
  20. +0 −24 lib/modules/afterStart.js
  21. +119 −38 lib/modules/console.js
  22. +210 −0 lib/modules/watchdog.js
  23. +48 −10 lib/monitor/monitor.js
  24. +12 −1 lib/pomelo.js
  25. +2 −2 lib/server/server.js
  26. +175 −0 lib/util/appUtil.js
  27. +1 −1 lib/util/countDownLatch.js
  28. +6 −0 lib/util/events.js
  29. +2 −2 lib/util/log.js
  30. +34 −3 lib/util/pathUtil.js
  31. +8 −33 lib/util/utils.js
  32. +10 −7 package.json
  33. +0 −1 template/game-server/app.js
  34. +414 −0 test/application.js
  35. +0 −175 test/applicationTest.js
  36. +3 −3 test/filters/handler/{serialTest.js → serial.js}
  37. +3 −2 test/filters/handler/{timeTest.js → time.js}
  38. +3 −2 test/filters/handler/{timeoutTest.js → timeout.js}
  39. +2 −1 test/filters/rpc/{rpcLogTest.js → rpcLog.js}
  40. 0 test/mock-base/.gitignore
  41. 0 test/mock-base/app/.gitignore
  42. 0 test/mock-base/app/servers/.file-start-with-dot
  43. 0 test/mock-base/app/servers/.folder-start-with-dot/.gitignore
  44. 0 test/mock-base/app/servers/.gitignore
  45. 0 test/mock-base/app/servers/area/.gitignore
  46. 0 test/mock-base/app/servers/connector/.gitignore
  47. 0 test/mock-base/app/servers/connector/handler/.gitignore
  48. 0 test/mock-base/app/servers/connector/remote/.gitignore
  49. 0 test/mock-base/app/servers/other-file
  50. +1 −1 test/{pomeloTest.js → pomelo.js}
  51. +159 −0 test/service/channel.js
  52. +181 −0 test/service/channelService.js
  53. +0 −80 test/service/channelServiceTest.js
  54. +142 −0 test/service/connectionService.js
  55. +0 −82 test/service/connectionServiceTest.js
  56. +2 −1 test/service/{filterServiceTest.js → filterService.js}
  57. +2 −1 test/service/{handlerServiceTest.js → handlerService.js}
  58. +2 −1 test/service/{taskManagerTest.js → taskManager.js}
  59. +66 −0 test/util/countDownLatch.js
  60. +0 −50 test/util/countDownLatchTest.js
  61. +116 −0 test/util/pathUtil.js
  62. +84 −0 test/util/utils.js
View
@@ -3,7 +3,9 @@
"describe",
"it",
"before",
"beforeEach",
"after",
"afterEach",
"window",
"__resources__"
],
@@ -16,5 +18,6 @@
"immed": false,
"newcap": true,
"nonew": true,
"white": false
"white": false,
"strict": false
}
View
@@ -1,9 +1,21 @@
MOCHA_OPTS=
TESTS = test/*
REPORTER = spec
REPORTER = dot
TIMEOUT = 5000
test:
@./node_modules/.bin/mocha \
--reporter $(REPORTER) --timeout $(TIMEOUT) $(TESTS)
--reporter $(REPORTER) --timeout $(TIMEOUT) $(TESTS) \
$(MOCHA_OPTS)
.PHONY: test
test-cov: lib-cov
@POMELO_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
lib-cov:
@jscoverage lib lib-cov
clean:
rm -f coverage.html
rm -fr lib-cov
.PHONY: test clean
View
@@ -42,11 +42,10 @@ var NOWORKSPACE_ERROR = 'Please go to your game-server directory to start the ap
var COMMAND_ERROR = 'The command is error format.';
var INSTALLFOREVER_ERROR = 'Please install forever use command: npm install forever -g.';
var CONNECT_ERROR = 'Fail to connect to admin console server.';
var NODEINFO_ERROR = 'Fail to request node information.';
var STOPSERVER_ERROR = 'Fail to stop server.';
var FILEREAD_ERROR = 'Fail to read the file, please check if the application is started legally.';
var RUNDAEMON_INFO = 'Application run in daemon.\nStop the application use the command:pomelo stop.';
var CLOSEAPP_INFO = 'Closing the application......\nPlease wait......';
var ADDSUCCESS_INFO = 'Successfully add server.';
/**
* Usage documentation.
@@ -80,8 +79,10 @@ var args = process.argv.slice(2);
case 'start':
start();
break;
case 'add':
add();
break;
case 'stop':
legalArgNum(0);
terminal('stop');
break;
case 'kill':
@@ -201,10 +202,7 @@ function list() {
client.request(co.moduleId, {
signal: 'list'
}, function(err, data) {
if(err) {
console.error(err);
abort(NODEINFO_ERROR);
}
if(err) console.error(err);
var msg = data.msg;
var rows = [];
rows.push(['serverId', 'serverType', 'pid', 'heapUsed(M)', 'uptime(m)']);
@@ -221,14 +219,39 @@ function list() {
} else abort(NOWORKSPACE_ERROR);
};
/**
* Add server to application.
*
*/
function add() {
if(IF_WORKSPACE) {
fs.readFile(TMP_FILE, function(err, data) {
if(err) abort(FILEREAD_ERROR);
var client = new adminClient();
MASTER_JSON = require(MASTER_CONFIG);
var config = MASTER_JSON[data.toString().split(':')[0]];
var id = 'pomelo_add_' + Date.now();
client.connect(id, config.host, config.port, function(err) {
if(err) abort(CONNECT_ERROR);
else {
client.request(co.moduleId, {signal: 'add', args:args},function(err, msg) {
if(err) console.error(err);
else console.info(ADDSUCCESS_INFO);
process.exit(0);
});
}
});
});
}
};
/**
* Terminal application.
*
* @param {String} signal stop/kill
*
*/
function terminal(signal) {
if(args.length > 1 || (args.length === 1 && args[0] !== '--force')) abort(COMMAND_ERROR);
if(IF_WORKSPACE) {
console.info(CLOSEAPP_INFO);
if(args[0] === '--force') {
@@ -241,7 +264,7 @@ function terminal(signal) {
MASTER_JSON = require(MASTER_CONFIG);
var config = MASTER_JSON[data.toString().split(':')[0]];
var id = 'pomelo_terminal_' + Date.now();
if(data.toString().split(':')[1] == 'true') {
if(data.toString().split(':')[1] === 'true' && args.length === 0) {
setTimeout(function() {
if(IF_HOME) exec('forever stop app.js');
else exec('cd game-server && forever stop app.js');
@@ -251,12 +274,11 @@ function terminal(signal) {
client.connect(id, config.host, config.port, function(err) {
if(err) abort(CONNECT_ERROR);
client.request(co.moduleId, {
signal: signal
signal: signal, ids: args
}, function(err, msg) {
if(err) abort(STOPSERVER_ERROR);
if(msg.status === "error") abort(STOPSERVER_ERROR);
if(err) console.error(err);
setTimeout(function() {
fs.unlinkSync(TMP_FILE);
if(msg.status === 'all') fs.unlinkSync(TMP_FILE);
process.exit(0);
}, TIME_KILL_WAIT);
});
View
@@ -1 +1,3 @@
module.exports = require('./lib/pomelo');
module.exports = process.env.POMELO_COV ?
require('./lib-cov/pomelo') :
require('./lib/pomelo');
Oops, something went wrong.

0 comments on commit baa5845

Please sign in to comment.