here is an even simpler option https://github.com/felixge/node-growing-file

it uses the approach @hasanyasin recommends, and exposes it as a stream.

On Thu, Jul 5, 2012 at 9:20 AM, mscdex <msc...@gmail.com> wrote:
> On Jul 4, 5:15 pm, mscdex <msc...@gmail.com> wrote:
>> On Jul 4, 4:20 pm, hasanyasin <hasanya...@gmail.com> 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 nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to