Skip to content

Instantly share code, notes, and snippets.

@pgte
Created September 15, 2010 11:48
Show Gist options
  • Save pgte/580618 to your computer and use it in GitHub Desktop.
Save pgte/580618 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
spawn = require('child_process').spawn,
http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
var tail = spawn('tail', ['-f', '/var/log/system.log']);
var kill_tail = function() {
tail.kill();
}
process.on('exit', kill_tail);
request.connection.on('end', kill_tail);
tail.stdout.on('data', function(data) {
response.write(data);
});
}).listen(8124);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment