[Supervisor-users] scheduled start and stop time?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Supervisor-users] scheduled start and stop time?

Steve Lorimer
Is there a way to schedule a window during which a service should be running?

Similar to cron, but managed through supervisord?

[program:theprogramname]
command=/bin/cat
starttime=09:00:00
stoptime=17:00:00
dow=1-5
dom=*
month=*

If this isn't available in supervisord directly, what is the recommended way to achieve this?

TIA
Steve


_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Aryeh Leib Taurog-2
I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
and for the most part I make the processes themselves responsible for
exiting at the right time (say, after market close).

I also make the processes responsible for handling changes in start
time due to other factors like daylight savings.  The cron jobs start
everything before the earliest time and the processes sleep until the
correct start time for the current date.

On Wed, Jun 10, 2015 at 02:36:34PM +1000, Steve Lorimer wrote:

> Is there a way to schedule a window during which a service should be
> running?
>
> Similar to cron, but managed through supervisord?
>
> [program:theprogramname]
> command=/bin/cat
> starttime=09:00:00
> stoptime=17:00:00
> dow=1-5
> dom=*
> month=*
>
> If this isn't available in supervisord directly, what is the recommended
> way to achieve this?
>
> TIA
> Steve

> _______________________________________________
> Supervisor-users mailing list
> [hidden email]
> https://lists.supervisord.org/mailman/listinfo/supervisor-users

_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

jon bennett
If you're using supervisor and have the logic to allow your processes
to sleep, why not make your processes persistent and leave it to them
to know when to run?
You then have a clear separation of concerns, Supervisor makes sure
the process is running (or stopped!) and the process makes sure it
only does things when it should do.

On 10 June 2015 at 09:55, Aryeh Leib Taurog <[hidden email]> wrote:

> I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
> and for the most part I make the processes themselves responsible for
> exiting at the right time (say, after market close).
>
> I also make the processes responsible for handling changes in start
> time due to other factors like daylight savings.  The cron jobs start
> everything before the earliest time and the processes sleep until the
> correct start time for the current date.
>
> On Wed, Jun 10, 2015 at 02:36:34PM +1000, Steve Lorimer wrote:
>> Is there a way to schedule a window during which a service should be
>> running?
>>
>> Similar to cron, but managed through supervisord?
>>
>> [program:theprogramname]
>> command=/bin/cat
>> starttime=09:00:00
>> stoptime=17:00:00
>> dow=1-5
>> dom=*
>> month=*
>>
>> If this isn't available in supervisord directly, what is the recommended
>> way to achieve this?
>>
>> TIA
>> Steve
>
>> _______________________________________________
>> Supervisor-users mailing list
>> [hidden email]
>> https://lists.supervisord.org/mailman/listinfo/supervisor-users
>
> _______________________________________________
> Supervisor-users mailing list
> [hidden email]
> https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

jon bennett
> If you're using supervisor and have the logic to allow your processes
> to sleep, why not make your processes persistent and leave it to them
> to know when to run?

s/run/do-something

> You then have a clear separation of concerns, Supervisor makes sure
> the process is running (or stopped!) and the process makes sure it
> only does things when it should do.
>
> On 10 June 2015 at 09:55, Aryeh Leib Taurog <[hidden email]> wrote:
>> I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
>> and for the most part I make the processes themselves responsible for
>> exiting at the right time (say, after market close).
>>
>> I also make the processes responsible for handling changes in start
>> time due to other factors like daylight savings.  The cron jobs start
>> everything before the earliest time and the processes sleep until the
>> correct start time for the current date.
>>
>> On Wed, Jun 10, 2015 at 02:36:34PM +1000, Steve Lorimer wrote:
>>> Is there a way to schedule a window during which a service should be
>>> running?
>>>
>>> Similar to cron, but managed through supervisord?
>>>
>>> [program:theprogramname]
>>> command=/bin/cat
>>> starttime=09:00:00
>>> stoptime=17:00:00
>>> dow=1-5
>>> dom=*
>>> month=*
>>>
>>> If this isn't available in supervisord directly, what is the recommended
>>> way to achieve this?
>>>
>>> TIA
>>> Steve
>>
>>> _______________________________________________
>>> Supervisor-users mailing list
>>> [hidden email]
>>> https://lists.supervisord.org/mailman/listinfo/supervisor-users
>>
>> _______________________________________________
>> Supervisor-users mailing list
>> [hidden email]
>> https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Aryeh Leib Taurog-2
In reply to this post by jon bennett
Prefork webservers like gunicorn are usually configured to limit the
number of requests each worker can serve, for various reasons.  My
model is based on similar motivations.  It simplifies resource
management and the scheduling logic, among other things.

So to be more precise, most of my processes are in fact set to
autostart.  They manage their own scheduling logic, and most of the
cron jobs do `supervisorctl restart suchandsuch` which generally is
expected to produce an error because the process will have exited
normally at the end of the previous run.

Perhaps not intuitive, and definitely not a complete separation of
concerns as you point out, but I also don't see why I should
reimplement in my own codebase what I have for free in cron.

On Wed, Jun 10, 2015 at 01:54:39PM +0100, jon bennett wrote:

> If you're using supervisor and have the logic to allow your processes
> to sleep, why not make your processes persistent and leave it to them
> to know when to run?
> You then have a clear separation of concerns, Supervisor makes sure
> the process is running (or stopped!) and the process makes sure it
> only does things when it should do.
>
> On 10 June 2015 at 09:55, Aryeh Leib Taurog <[hidden email]> wrote:
> > I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
> > and for the most part I make the processes themselves responsible for
> > exiting at the right time (say, after market close).
> >
> > I also make the processes responsible for handling changes in start
> > time due to other factors like daylight savings.  The cron jobs start
> > everything before the earliest time and the processes sleep until the
> > correct start time for the current date.
> >
> > On Wed, Jun 10, 2015 at 02:36:34PM +1000, Steve Lorimer wrote:
> >> Is there a way to schedule a window during which a service should be
> >> running?
> >>
> >> Similar to cron, but managed through supervisord?
> >>
> >> [program:theprogramname]
> >> command=/bin/cat
> >> starttime=09:00:00
> >> stoptime=17:00:00
> >> dow=1-5
> >> dom=*
> >> month=*
> >>
> >> If this isn't available in supervisord directly, what is the recommended
> >> way to achieve this?
> >>
> >> TIA
> >> Steve
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Timothy Jones
In reply to this post by jon bennett
-----Original Message-----
> If you're using supervisor and have the logic to allow your processes
> to sleep, why not make your processes persistent and leave it to them
> to know when to do something?

I concur this works well.  I have hundreds of supervisor child processes that spent most of their time in a sleep() call, but wake up every 15 minutes (xx:00, xx:15, xx:30, xx:45) to run a few summarization SQL scripts for the previous time period, then go right back to sleep.

Supervisor thinks they are busy 24/7, but they're not.



tlj
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Steve Lorimer
In reply to this post by Steve Lorimer
From: Aryeh Leib Taurog <[hidden email]>

> I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
and for the most part I make the processes themselves responsible for
exiting at the right time (say, after market close).

This is what I was leaning towards, but it seems a bit unproductive to manage two sets of app configuration, 1 in supervisord and 1 in cron - I would prefer to be able to specify start and stop times in my supervisord config and have it supervise the starting and stopping

> I also make the processes responsible for handling changes in start
time due to other factors like daylight savings.  The cron jobs start
everything before the earliest time and the processes sleep until the
correct start time for the current date.

This is an interesting concept, clever solution to a common problem.

Thanks for the input
~Steve

_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Paul Lockaby-2

> On Jun 10, 2015, at 3:55 PM, Steve Lorimer <[hidden email]> wrote:
>
> From: Aryeh Leib Taurog <[hidden email]>
>
> > I have a bunch of cron jobs that run `supervisorctl start suchandsuch`
> > and for the most part I make the processes themselves responsible for
> > exiting at the right time (say, after market close).
>
> This is what I was leaning towards, but it seems a bit unproductive to manage two sets of app configuration, 1 in supervisord and 1 in cron - I would prefer to be able to specify start and stop times in my supervisord config and have it supervise the starting and stopping
>
> > I also make the processes responsible for handling changes in start
> > time due to other factors like daylight savings.  The cron jobs start
> > everything before the earliest time and the processes sleep until the
> > correct start time for the current date.
>
> This is an interesting concept, clever solution to a common problem.
>
> Thanks for the input
> ~Steve
> _______________________________________________
> Supervisor-users mailing list
> [hidden email]
> https://lists.supervisord.org/mailman/listinfo/supervisor-users


Another alternative that I followed is to create a program that runs in supervisor and starts your programs on a schedule: https://github.com/plockaby/supervisor-tools

-Paul
_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Steve Lorimer

Another alternative that I followed is to create a program that runs in supervisor and starts your programs on a schedule: https://github.com/plockaby/supervisor-tools

 
Nice, thanks Paul - I'll check it out
 


_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Reply | Threaded
Open this post in threaded view
|

Re: [Supervisor-users] scheduled start and stop time?

Mikko Ohtamaa


On 10 June 2015 at 16:35, Steve Lorimer <[hidden email]> wrote:

Another alternative that I followed is to create a program that runs in supervisor and starts your programs on a schedule: https://github.com/plockaby/supervisor-tools

 
Nice, thanks Paul - I'll check it out

If you decide to write a program that runs inside supervisor, I can highly recommend Advanced Python Scheduler. It's a library which makes writing cron-like functionality in Python a joy:

http://apscheduler.readthedocs.org/

Cheers,
Mikko

_______________________________________________
Supervisor-users mailing list
[hidden email]
https://lists.supervisord.org/mailman/listinfo/supervisor-users