Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require('http');
- var spawn = require('child_process').spawn;
- http.createServer(onRequest).listen(4000);
- function onRequest(request, response)
- {
- response.writeHead(200, {'Content-Type' : 'text/plain'});
- var tail_child = spawn('tail', ['-f', '/var/log/system.log']);
- request.connection.on('end', onEnd);
- tail_child.stdout.on('data', onLoadData);
- function onEnd()
- {
- tail_child.kill();
- }
- function onLoadData(data)
- {
- console.log(data.toString());
- response.write(data);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement