Created
June 13, 2010 12:27
-
-
Save anonymous/436620 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 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