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
38
app/Bootstrap/server.js
Normal file → Executable file
38
app/Bootstrap/server.js
Normal file → Executable file
|
|
@ -1,36 +1,16 @@
|
||||||
var requirejs = require('requirejs');
|
define([
|
||||||
|
|
||||||
var inspector = {};
|
|
||||||
|
|
||||||
requirejs.config({
|
|
||||||
nodeRequire: require,
|
|
||||||
baseUrl: 'lib'
|
|
||||||
});
|
|
||||||
|
|
||||||
var requirements = [
|
|
||||||
"Server/HttpServer",
|
"Server/HttpServer",
|
||||||
"Server/Socket",
|
"Server/Socket",
|
||||||
"Server/Coordinator"
|
"Server/Coordinator"
|
||||||
];
|
],
|
||||||
|
|
||||||
var port = process.argv[2]
|
function(HttpServer, Socket, Coordinator) {
|
||||||
|| process.env.PORT
|
|
||||||
|| process.env.npm_package_config_port;
|
|
||||||
|
|
||||||
requirejs(requirements, function(HttpServer, Socket, Coordinator) {
|
function Server(options) {
|
||||||
|
this.coordinator = new Coordinator();
|
||||||
|
this.httpServer = new HttpServer(options);
|
||||||
|
this.socket = new Socket(httpServer.getServer(), options, coordinator);
|
||||||
|
}
|
||||||
|
|
||||||
var options = {
|
return Server;
|
||||||
port: port,
|
|
||||||
rootDirectory: './',
|
|
||||||
caching: false,
|
|
||||||
logLevel: process.argv[3]
|
|
||||||
};
|
|
||||||
|
|
||||||
var coordinator = new Coordinator();
|
|
||||||
var httpServer = new HttpServer(options);
|
|
||||||
var socket = new Socket(httpServer.getServer(), options, coordinator);
|
|
||||||
|
|
||||||
inspector.coordinator = coordinator;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
exports = module.exports = inspector;
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue