Hi Stephen,
The built-in watchdog will cater for this situation. If you set
autostate_delay to 60 and enable autostate, the watchdog will cause the
watch_files loop to be interrupted at least every 60 seconds and
running(0) will be recognised. It will also save state. Arguably the
autostate and loop checking functions should be separated - but that's
the way it works at the moment.
Regards,
--
Jon Schutz
CTO, YourAmigo Ltd
53 Gilbert St
Adelaide SA 5000
Ph: +61 8 82119211
Fax: +61 8 8211 6356
http://www.youramigo.com
On 01/10/13 06:42, Stephen Sprague via RT wrote:
Show quoted text> Queue: File-Tail-Dir
> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=88995 >
>
> Hi Jon,
> This isn't a bug but it would still be great to get your feedback.
>
> Here's my current dilemma. How can i exit the tailing process,
> watch_files(), programmatically from my code? I know about your running(0)
> method but its kinda hard to call it when my process_lines method isn't
> invoked. The simple case is an empty file. My callback is never called so
> i can't do anything to stop your module's event loop - from what i can tell
> anyway.
>
> In my case, if i don't get any records for 1 minute i can assume no more
> records will ever be written to the file i'm tailing - so i'd like to exit
> gracefully. I was thinking maybe a heartbeat type of callback could be
> employed in your module that you could call when in a wait mode. Then
> execution comes back to my code. just a thought.
>
> Anyhoo, what would you recommend in this case?
>
> thanks,
> stephen sprague
> spragues@gmail.com
>
>
> On Fri, Sep 27, 2013 at 8:52 AM, Stephen Sprague <spragues@gmail.com> wrote:
>
>> Thanks so much Jon. The way you're storing state is really a bang up job
>> and pretty hard-core. Its looks like you meant business when you started
>> off on this! :)
>>
>> I'm using it to feed Kafka (LinkedIn's opensource pub/sub app) and so far
>> things look great!
>>
>> Thanks again.
>>
>> Cheers,
>> stephen sprague
>> spragues@gmail.com
>>
>>
>> On Thu, Sep 26, 2013 at 11:05 PM, Jon Schutz via RT <
>> bug-File-Tail-Dir@rt.cpan.org> wrote:
>>
>>> <URL:
https://rt.cpan.org/Ticket/Display.html?id=88995 >
>>>
>>> Hi Stephen,
>>>
>>> Funny how such issues can live undetected for so long. Fixed in release
>>> 0.16.
>>>
>>> Regards,
>>>
>>> Jon Schutz
>>>
>>> On Fri Sep 27 01:21:37 2013, spragues@gmail.com wrote:
>>>> Hi Jon,
>>>>
>>>> i'm really curious if this ever finds its way to you. been using
>>>> File::Tail::Dir for a couple of days now and i really like it. thanks so
>>>> much for making it public!
>>>>
>>>> one thing. it seems when i set $tailer->runnning(0) the module will
>>>> eventually end its loop and call _stop_watchdog. it appears that
>>> method is
>>>> missing. figured you might want to know about it.
>>>>
>>>> i've put an eval {} around the watch_files() and just exit when the
>>> error
>>>> is caught. I'm thinking there isn't much of any cleanup to do since the
>>>> state was saved prior to the _stop_watchdog call.
>>>>
>>>> anyway. that's it. and thanks again for the module.
>>>>
>>>> cheers,
>>>> stephen sprague
>>>> spragues@gmail.com
>>>
>>>
>>>