Created
September 15, 2010 11:48
-
-
Save pgte/580618 to your computer and use it in GitHub Desktop.
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
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