Skip to content

Instantly share code, notes, and snippets.

Created June 13, 2010 12:27
Show Gist options
  • Select an option

  • Save anonymous/436620 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/436620 to your computer and use it in GitHub Desktop.
var sys = require('sys')
var filename = process.ARGV[2];
if (!filename)
return sys.puts("Usage: node watcher.js filename");
var spawn = require('child_process').spawn;
var tail = spawn("tail", ["-f", filename]);
sys.puts("start tailing");
var http = require("http");
http.createServer(function(req,res){
sys.puts("create server");
res.writeHead(200,{'Content-Length': body.length, 'Content-Type': 'text/plain'});
tail.stdout.addListener('data', function (data) {
sys.puts("add listener called in server");
res.write(data);
res.end();
});
}).Listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment