1
0
Fork 0

splite backend

This commit is contained in:
WEBXOSS 2017-03-05 14:14:50 +08:00
parent da5cb0b528
commit 41cdea88f6
2 changed files with 31 additions and 22 deletions

51
test.js
View file

@ -42,30 +42,39 @@ if (global.window) {
}); });
} }
} else { } else {
var express = require('express'); var noStaticServe = process.argv.slice(2).some(function (arg) {
var compression = require('compression'); return arg === '--no-static-server';
var app = express(); });
var server = require('http').Server(app); // static server
app.use(compression()); if (!noStaticServe) {
app.use('/background',express.static(__dirname + '/webxoss-client/images',{ var express = require('express');
maxAge: '2h' var compression = require('compression');
})); var app = express();
app.use('/images',express.static(__dirname + '/webxoss-client/images',{ var server = require('http').Server(app);
maxAge: '30d' app.use(compression());
})); app.use('/background',express.static(__dirname + '/webxoss-client/images',{
app.use(express.static(__dirname + '/webxoss-client')); maxAge: '2h'
io = require('socket.io')(server,{ }));
app.use('/images',express.static(__dirname + '/webxoss-client/images',{
maxAge: '30d'
}));
app.use(express.static(__dirname + '/webxoss-client'));
var port = 80;
process.argv.slice(2).forEach(function (arg) {
var match = arg.match(/^port=(\d+)/)
if (match) {
port = +match[1];
}
});
server.listen(port);
}
// game server
var gameServer = new require('http').createServer();
io = require('socket.io')(gameServer,{
pingTimeout: 30000, pingTimeout: 30000,
maxHttpBufferSize: 1024*1024, maxHttpBufferSize: 1024*1024,
}); });
var port = 80; gameServer.listen(2015);
process.argv.slice(2).forEach(function (arg) {
var match = arg.match(/^port=(\d+)/)
if (match) {
port = +match[1];
}
});
server.listen(port);
} }
var cfg = { var cfg = {

@ -1 +1 @@
Subproject commit 5bd921d1ee0257ed2eea4db66e821f72db8f26ae Subproject commit b69cfabd41cbea0059b03891f0a4c900fe2dbb09