Created
May 21, 2013 23:50
-
-
Save anonymous/5624232 to your computer and use it in GitHub Desktop.
server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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