Skip Menu |

This queue is for tickets about the File-Tail-Dir CPAN distribution.

Report information
The Basics
Id: 60492
Status: resolved
Priority: 0/
Queue: File-Tail-Dir

People
Owner: Nobody in particular
Requestors: gsab.cpn [...] holistec.ca
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Auto State Save
Hello Jon, Very good job with this module! I was looking for tail tools to write my own log monitor, and came across your module which does exactly what we were looking for. This is very nice code! I did however made a small addition to your module to make sure the state file is saved regularly, to prevent/reduce duplicate logging if the server ever crashes hard. If you are interested for more info, let me know! I tried to reach you other ways (forum, your notes site), but this did not work, so I'm using CPAN bug reports for this. Thanks, Guy
Subject: Re: [rt.cpan.org #60492] Auto State Save
Date: Thu, 19 Aug 2010 13:20:02 +0930
To: bug-File-Tail-Dir [...] rt.cpan.org
From: Jon Schutz <jon [...] jschutz.net>
Hi Guy, Sounds like a good idea. I'd be happy to look at your patch. Please add to this ticket or send to me at jon at jschutz.net. Regards, On 19/08/10 13:17, Guy Sabourin via RT wrote: Show quoted text
> Wed Aug 18 23:47:09 2010: Request 60492 was acted upon. > Transaction: Ticket created by guysab > Queue: File-Tail-Dir > Subject: Auto State Save > Broken in: (no value) > Severity: Wishlist > Owner: Nobody > Requestors: gsab.cpn@holistec.ca > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=60492 > > > > Hello Jon, > > Very good job with this module! I was looking for tail tools to write my own log monitor, and > came across your module which does exactly what we were looking for. This is very nice code! > > I did however made a small addition to your module to make sure the state file is saved > regularly, to prevent/reduce duplicate logging if the server ever crashes hard. If you are > interested for more info, let me know! I tried to reach you other ways (forum, your notes site), > but this did not work, so I'm using CPAN bug reports for this. > > Thanks, > > Guy >
-- Jon Schutz http://notes.jschutz.net
From: gsab.cpn [...] holistec.ca
On Wed Aug 18 23:50:14 2010, jon@jschutz.net wrote: Hi Jon, Here's the patch file of the change I did. I added comments to the perldoc for you. Basically, the patch saves the state file whenever watch_files() goes idle. As a small kludge, I've also added an optional delay to reduce the overhead if the files ever get updated *very* frequently (which can happen very fast when inotify is used). Please feel free to re-implement this, if and however you see fit! Again, kudos for this very nice module. It's extremely well written, clean, and very efficient! Guy
Subject: FileTailDirLQ.pm.patch
22a23,32 > has 'autostate' => ( > is => 'rw', > isa => 'Int', > default => 0, > ); > has 'autostate_delay' => ( > is => 'rw', > isa => 'Int', > default => 0, > ); 372c382,388 < $self->_clear_inode_list(); --- > if ( $self->autostate ) { > # print "Storing autostate...\n"; > $self->save_state(); > sleep $self->autostate_delay if $self->autostate_delay; > } else { > $self->_clear_inode_list(); > } 540a557,565 > =item * autostate => 1|0 > > Set to 1 to automatically store the state file after every file changes. Defaults to 0. > > =item * autostate_delay => $number > > Delays the next file scan by autostate_delay seconds after storing the state, to > reduce the overhead when files are updated very frequently. Defaults to 0 seconds. >
Hi Guy, I have incorporated this feature. It only took 2 years. Putting the call to sleep() in there bothered me from both a performance perspective and potential interference with SIGALRM, so instead I created a watchdog process that can force the wait_for_events() loop to break periodically. Regards, -- Jon Schutz http://notes.jschutz.net/ On Thu Aug 19 00:52:03 2010, guysab wrote: Show quoted text
> On Wed Aug 18 23:50:14 2010, jon@jschutz.net wrote: > > Hi Jon, > > Here's the patch file of the change I did. I added comments to the > perldoc for you. > > Basically, the patch saves the state file whenever watch_files() goes > idle. As a small kludge, I've > also added an optional delay to reduce the overhead if the files ever > get updated *very* > frequently (which can happen very fast when inotify is used). > > Please feel free to re-implement this, if and however you see fit! > > Again, kudos for this very nice module. It's extremely well written, > clean, and very efficient! > > Guy