You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by "Alan D. Cabrera" <li...@toolazydogs.com> on 2013/12/16 16:33:47 UTC

Scheduling a recurrent task

I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?


Regards,
Alan


Re: Scheduling a recurrent task

Posted by James Peach <jp...@apache.org>.
On Dec 17, 2013, at 10:06 AM, Alan D. Cabrera <li...@toolazydogs.com> wrote:

> 
> On Dec 17, 2013, at 9:38 AM, James Peach <jp...@apache.org> wrote:
> 
>> On Dec 17, 2013, at 9:32 AM, Alan D. Cabrera <li...@toolazydogs.com> wrote:
>> 
>>> 
>>> On Dec 16, 2013, at 7:47 AM, Leif Hedstrom <zw...@apache.org> wrote:
>>> 
>>>> 
>>>> 
>>>>> On Dec 16, 2013, at 8:33 AM, "Alan D. Cabrera" <li...@toolazydogs.com> wrote:
>>>>> 
>>>>> I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?
>>>> 
>>>> Create a continuation and schedule it to run every so often on a TASK thread .
>>>> 
>>>> You can alternatively have the continuation scheduled for a single run, and have it reschedule itself. That's useful if the interval between invocations is not fixed.
>>> 
>>> As I consider it more carefully, I probably don't want to scan the file system for changes but, instead, should wait for traffic_line to tell my server to re-read configs.  Is there an event for that or does my plugin get restarted?
>> 
>> Is that a global or a remap plugin?
> 
> Both.

For remap plugins, you need to implement TSRemapNewInstance() and TSRemapDeleteInstance(), <https://trafficserver.readthedocs.org/en/latest/reference/api/TSRemap.en.html>.

For global plugins, you need to register a callback with TSMgmtUpdateRegister(), for example <https://github.com/apache/trafficserver/blob/master/plugins/gzip/gzip.cc#L798>.

J


Re: Scheduling a recurrent task

Posted by "Alan D. Cabrera" <li...@toolazydogs.com>.
On Dec 17, 2013, at 9:38 AM, James Peach <jp...@apache.org> wrote:

> On Dec 17, 2013, at 9:32 AM, Alan D. Cabrera <li...@toolazydogs.com> wrote:
> 
>> 
>> On Dec 16, 2013, at 7:47 AM, Leif Hedstrom <zw...@apache.org> wrote:
>> 
>>> 
>>> 
>>>> On Dec 16, 2013, at 8:33 AM, "Alan D. Cabrera" <li...@toolazydogs.com> wrote:
>>>> 
>>>> I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?
>>> 
>>> Create a continuation and schedule it to run every so often on a TASK thread .
>>> 
>>> You can alternatively have the continuation scheduled for a single run, and have it reschedule itself. That's useful if the interval between invocations is not fixed.
>> 
>> As I consider it more carefully, I probably don't want to scan the file system for changes but, instead, should wait for traffic_line to tell my server to re-read configs.  Is there an event for that or does my plugin get restarted?
> 
> Is that a global or a remap plugin?

Both.
Regards,
Alan


Re: Scheduling a recurrent task

Posted by James Peach <jp...@apache.org>.
On Dec 17, 2013, at 9:32 AM, Alan D. Cabrera <li...@toolazydogs.com> wrote:

> 
> On Dec 16, 2013, at 7:47 AM, Leif Hedstrom <zw...@apache.org> wrote:
> 
>> 
>> 
>>> On Dec 16, 2013, at 8:33 AM, "Alan D. Cabrera" <li...@toolazydogs.com> wrote:
>>> 
>>> I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?
>> 
>> Create a continuation and schedule it to run every so often on a TASK thread .
>> 
>> You can alternatively have the continuation scheduled for a single run, and have it reschedule itself. That's useful if the interval between invocations is not fixed.
> 
> As I consider it more carefully, I probably don't want to scan the file system for changes but, instead, should wait for traffic_line to tell my server to re-read configs.  Is there an event for that or does my plugin get restarted?

Is that a global or a remap plugin?

Re: Scheduling a recurrent task

Posted by "Alan D. Cabrera" <li...@toolazydogs.com>.
On Dec 16, 2013, at 7:47 AM, Leif Hedstrom <zw...@apache.org> wrote:

> 
> 
>> On Dec 16, 2013, at 8:33 AM, "Alan D. Cabrera" <li...@toolazydogs.com> wrote:
>> 
>> I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?
> 
> Create a continuation and schedule it to run every so often on a TASK thread .
> 
> You can alternatively have the continuation scheduled for a single run, and have it reschedule itself. That's useful if the interval between invocations is not fixed.

As I consider it more carefully, I probably don't want to scan the file system for changes but, instead, should wait for traffic_line to tell my server to re-read configs.  Is there an event for that or does my plugin get restarted?


Regards,
Alan


Re: Scheduling a recurrent task

Posted by Leif Hedstrom <zw...@apache.org>.

> On Dec 16, 2013, at 8:33 AM, "Alan D. Cabrera" <li...@toolazydogs.com> wrote:
> 
> I'm writing a plugin that performs a recurrent task, i.e. watches a file system for changes.  What's the best way to do this in a ATS plugin?

Create a continuation and schedule it to run every so often on a TASK thread .

You can alternatively have the continuation scheduled for a single run, and have it reschedule itself. That's useful if the interval between invocations is not fixed.

-- Leif 
> 
> 
> Regards,
> Alan
>