Created
January 14, 2011 12:21
-
-
Save seanhess/779541 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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