Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2013 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5624232 to your computer and use it in GitHub Desktop.
Save anonymous/5624232 to your computer and use it in GitHub Desktop.
server.js
/*jslint anon:true, sloppy:true, nomen:true*/
process.chdir(__dirname);
/*
* Create the MojitoServer instance we'll interact with. Options can be passed
* using an object with the desired key/value pairs.
*/
var Mojito = require('mojito');
var app = Mojito.createServer(),
port = process.argv[2] || 8008,
address = process.argv[3] || "0.0.0.0";
// ---------------------------------------------------------------------------
// Different hosting environments require different approaches to starting the
// server. Adjust below to match the requirements of your hosting environment.
// ---------------------------------------------------------------------------
var pidFile = "nodejs.pid";
var fs = require('fs');
fs.writeFile(pidFile, process.pid + "\n", function(err) {
if(err) {
console.log("Failed to write to pid file '" + pidFile + "' : " + err);
}
});
// 0x80DE
module.exports = app.listen(port, address);
console.log("Server started at "+address+" on port "+port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment