yeah i tried the growing file .. and it gives me the same result .. every so often instead of actually getting the new log line I get just a bunch of null characters .. that happens more when the logs are coming in fast .. and my log files are on a windows share which is mounted in the linux system where node is running .. one thing i noticed is that if i open up a couple of terminals doing a tail -f on the same file that node is doing the watchFile on .. all 3 processes gets stuck .. once i kill one of two of them then the watchFile starts seeing changes .. does that indicates may be where my problem is ?
On Friday, July 27, 2012 2:03:47 PM UTC-5, Roly Fentanes wrote: > > I don't know what is wrong with your particular code. But take a look at > https://github.com/felixge/node-growing-file > > On Friday, July 27, 2012 9:11:05 AM UTC-7, Adeel Qureshi wrote: >> >> I am reading a growing file and showing its contents in the browser .. >> here is my implementation for reading the file >> >> //start watching the file >> fs.watchFile(filename, {persistent:true, >> interval:1000}, function(curr, prev){ >> if(prev.size > curr.size) >> callback(null); >> //open stream >> var stream = >> fs.createReadStream(filename, {start:prev.size, end:curr.size, >> encoding:'utf8'}); >> stream.on('data', function(data){ >> //emit new data >> socket.emit('log', fileId, >> data.split('\r\n')); >> }); >> stream.on('error', function(err){ >> if(err) throw err; >> }); >> }); >> >> this seems to work fine overall but for some strange reason it cant parse >> out some lines that are added to the file and the lines dont seem to be >> consistent .. e.g. the same line will be read fine if it shows up again but >> every once in a while it just reads the whole line as null characters and >> emits data as something like >> >> debug: websocket writing >> 5:::{"name":"log","args":["coi-prod_wom201207260log",["\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000"]]} >> >> any ideas whats going on here >> >> Thanks >> Adeel >> > -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
