On Jul 4, 5:15 pm, mscdex <[email protected]> wrote: > On Jul 4, 4:20 pm, hasanyasin <[email protected]> wrote: > > > Did you take a look at the code example I gave? You do not need to use > > watch if your process is running and the file is being written constantly. > > For exact implementation of tail -f completely in Node, please take a look > > at the working code I had given the address for. > > IMHO it's best to use watchFile so that you don't perform a lot of > unnecessary polling stat calls (especially synchronous ones). > > Using fs.open + fs.watchFile + fs.fstat + fs.read is probably your > best bet.
With regards to the linked stackoverflow example, it's best to avoid creating a new Buffer every time you read. You should also either: keep reading from the file while the current position is less than the last checked file size and avoid extra unnecessary stat calls until you are finished, or just read the whole delta (current file size - current position) from the get-go instead of one small chunk at a time. -- 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
