This commit is contained in:
GitHub Merge Button 2012-02-21 02:45:09 -08:00
commit 2674f9a6f6
5 changed files with 32 additions and 4 deletions

View file

@ -23,7 +23,7 @@ node-inspector &
echo "If you are new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" echo "If you are new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8"
cd "node" cd "node"
node --debug server.js node --debug serve.js
#kill node-inspector before ending #kill node-inspector before ending
kill $! kill $!

View file

@ -26,4 +26,4 @@ bin/installDeps.sh || exit 1
#Move to the node folder and start #Move to the node folder and start
echo "start..." echo "start..."
cd "node" cd "node"
node server.js node serve.js

1
node/serve.js Normal file
View file

@ -0,0 +1 @@
require("./server").init(function(){});

View file

@ -67,7 +67,15 @@ exports.maxAge = 1000*60*60*6;
//set loglevel //set loglevel
log4js.setGlobalLogLevel(settings.loglevel); log4js.setGlobalLogLevel(settings.loglevel);
async.waterfall([ function init(additionalSetup){
//additionalSetup is an optional argument that must be a function
//the purpose of additionalSetup is
//to allow whoever initializes the server to add functionality
//before the server begins listening
if("function" != typeof additionalSetup)
//the default value for initialSetup is a no-op
additionalSetup = function additionalSetup(app, db, managers, handlers){};
async.waterfall([
//initalize the database //initalize the database
function (callback) function (callback)
{ {
@ -402,6 +410,23 @@ async.waterfall([
}); });
}); });
//additionalSetup is a hook for modifying the app before it begins listening
//some things such a hook might need are the app itself, the database, and any managers and handlers it might want to use
//rather than passing the managers and handlers one by one, each of those collections is passed as a dictionary
additionalSetup(
app, db,
{
"ro": readOnlyManager,
pad: padManager,
security: securityManager
},
{
"export": exportHandler,
"import": importHandler,
api: apiHandler
}
);
//let the server listen //let the server listen
app.listen(settings.port, settings.ip); app.listen(settings.port, settings.ip);
console.log("Server is listening at " + settings.ip + ":" + settings.port); console.log("Server is listening at " + settings.ip + ":" + settings.port);
@ -492,3 +517,5 @@ async.waterfall([
callback(null); callback(null);
} }
]); ]);
}
this.init = init;

View file

@ -1,2 +1,2 @@
cd node cd node
..\bin\node server.js ..\bin\node serve.js