Skip to content

Instantly share code, notes, and snippets.

@Slashed
Created March 26, 2010 01:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Slashed/344368 to your computer and use it in GitHub Desktop.
Save Slashed/344368 to your computer and use it in GitHub Desktop.
var daemon = require('./daemon');
var sys = require('sys');
var fs = require('fs');
var http = require('http');
var config = {
lockFile: '/tmp/hellohttpd.lock' //Location of lockFile
};
var args = process.argv;
var dPID;
switch(args[2]) {
case "stop":
process.kill(parseInt(fs.readFileSync(config.lockFile)));
process.exit(0);
break;
case "start":
dPID = daemon.start();
daemon.lock(config.lockFile);
daemon.closeIO();
break;
default:
sys.puts('Usage: [start|stop]');
process.exit(0);
}
http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('<h1>Hello, World!</h1>');
res.close();
}).listen(8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment