mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added serverside bootstrapping
This commit is contained in:
parent
10950c4f5a
commit
2f430b15e0
1 changed files with 10 additions and 30 deletions
40
app/Bootstrap/server.js
Normal file → Executable file
40
app/Bootstrap/server.js
Normal file → Executable file
|
|
@ -1,36 +1,16 @@
|
|||
var requirejs = require('requirejs');
|
||||
|
||||
var inspector = {};
|
||||
|
||||
requirejs.config({
|
||||
nodeRequire: require,
|
||||
baseUrl: 'lib'
|
||||
});
|
||||
|
||||
var requirements = [
|
||||
define([
|
||||
"Server/HttpServer",
|
||||
"Server/Socket",
|
||||
"Server/Coordinator"
|
||||
];
|
||||
],
|
||||
|
||||
var port = process.argv[2]
|
||||
|| process.env.PORT
|
||||
|| process.env.npm_package_config_port;
|
||||
function(HttpServer, Socket, Coordinator) {
|
||||
|
||||
requirejs(requirements, function(HttpServer, Socket, Coordinator) {
|
||||
|
||||
var options = {
|
||||
port: port,
|
||||
rootDirectory: './',
|
||||
caching: false,
|
||||
logLevel: process.argv[3]
|
||||
};
|
||||
function Server(options) {
|
||||
this.coordinator = new Coordinator();
|
||||
this.httpServer = new HttpServer(options);
|
||||
this.socket = new Socket(httpServer.getServer(), options, coordinator);
|
||||
}
|
||||
|
||||
var coordinator = new Coordinator();
|
||||
var httpServer = new HttpServer(options);
|
||||
var socket = new Socket(httpServer.getServer(), options, coordinator);
|
||||
|
||||
inspector.coordinator = coordinator;
|
||||
});
|
||||
|
||||
exports = module.exports = inspector;
|
||||
return Server;
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue