javascript - Node.js how to keep on reading a text file -
i'm trying read text file. text file updated everytime event occurs in c program in linux.
here's code.
var http = require('http'), fs = require('fs'); var filetoread = fs.readfilesync('this_is_a_log.txt'); server = http.createserver(); server.on('request', function(req, res){ res.writehead(200, {'content-type': 'text/html'}); res.end(filetoread); }); server.listen(9000);
how can node.js continue reading text file page keeps updated everytime text file modified. don't want use delay or timeout, want real time. there function in node.js can this. don't want use tail.
Comments
Post a Comment