Skip to content

Instantly share code, notes, and snippets.

@seanhess
Created January 14, 2011 12:21
Show Gist options
  • Save seanhess/779541 to your computer and use it in GitHub Desktop.
Save seanhess/779541 to your computer and use it in GitHub Desktop.
var tail = spawn("tail", ["-f", LogPath])
tail.stdout.on('data', function(data) {
sys.puts("IN " + data)
})
tail.stderr.on('data', function(data) {
sys.puts("ERR " + data)
})
var server = http.createServer(function(request, response) {
if (request.url == "/") {
response.writeHead(200, {'Content-Type': "text/html"})
response.write("<h1>DeathStar CI Server</h1>")
response.write("<a href='/log/tail'>/log/tail</a><br>")
response.end()
}
else if (request.url == "/log/tail") {
response.writeHead(200, {'Content-Type': "text/plain"})
response.write("woot\n", "utf8")
function stream(data) {
response.write(data, "utf8")
// response.end()
}
request.on('end', function() {
// sys.puts("ENDED REQUEST")
// tail.stdout.removeListener('data', stream)
// tail.stdin.removeListener('data', stream)
})
sys.puts("Adding?")
tail.stdout.on('data', stream)
tail.stderr.on('data', stream)
// response.end()
}
}).listen(80)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment