Discussion:
[Supervisor-users] scheduled start and stop time?
Steve Lorimer
2015-06-10 04:36:34 UTC
Permalink
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
Aryeh Leib Taurog
2015-06-10 08:55:23 UTC
Permalink
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.
Post by 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
https://lists.supervisord.org/mailman/listinfo/supervisor-users
jon bennett
2015-06-10 12:54:39 UTC
Permalink
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.
Post by Aryeh Leib Taurog
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.
Post by 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
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
jon bennett
2015-06-10 12:55:29 UTC
Permalink
Post by 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
Post by jon bennett
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.
Post by Aryeh Leib Taurog
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.
Post by 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
https://lists.supervisord.org/mailman/listinfo/supervisor-users
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Timothy Jones
2015-06-10 15:04:47 UTC
Permalink
-----Original Message-----
Post by 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 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
Aryeh Leib Taurog
2015-06-10 13:18:15 UTC
Permalink
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.
Post by 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.
Post by Aryeh Leib Taurog
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.
Post by 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
Steve Lorimer
2015-06-10 22:55:49 UTC
Permalink
Post by Aryeh Leib Taurog
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
Post by Aryeh Leib Taurog
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
Paul Lockaby
2015-06-10 23:01:47 UTC
Permalink
Post by Aryeh Leib Taurog
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
Post by Aryeh Leib Taurog
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
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
Steve Lorimer
2015-06-10 23:35:48 UTC
Permalink
Post by Paul Lockaby
Another alternative that I followed is to create a program that runs in
https://github.com/plockaby/supervisor-tools
Nice, thanks Paul - I'll check it out
Mikko Ohtamaa
2015-06-10 23:38:34 UTC
Permalink
Post by Steve Lorimer
Post by Paul Lockaby
Another alternative that I followed is to create a program that runs in
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

Continue reading on narkive:
Loading...