misc: run hourly jobs at a fixed minute (#25402)
This commit is contained in:
parent
c636147a3f
commit
320bf52374
|
@ -114,8 +114,7 @@ class WcsPublisher(StubWcsPublisher):
|
|||
def register_cronjobs(cls):
|
||||
super(WcsPublisher, cls).register_cronjobs()
|
||||
# every hour: check for global action timeouts
|
||||
cls.register_cronjob(CronJob(cls.apply_global_action_timeouts,
|
||||
minutes=[random.randint(0, 59)]))
|
||||
cls.register_cronjob(CronJob(cls.apply_global_action_timeouts, hourly=True))
|
||||
|
||||
def is_using_postgresql(self):
|
||||
return bool(self.has_site_option('postgresql') and self.cfg.get('postgresql', {}))
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
class CronJob(object):
|
||||
hours = None
|
||||
minutes = None
|
||||
|
@ -23,12 +25,16 @@ class CronJob(object):
|
|||
days = None
|
||||
function = None
|
||||
|
||||
def __init__(self, function, hours = None, minutes = None, weekdays = None, days = None):
|
||||
def __init__(self, function, hours=None, minutes=None, weekdays=None, days=None, hourly=False):
|
||||
self.function = function
|
||||
self.hours = hours
|
||||
self.minutes = minutes
|
||||
self.weekdays = weekdays
|
||||
self.days = days
|
||||
if hourly:
|
||||
# set minutes to an arbitrary value based on installation, this
|
||||
# prevents waking up all jobs at the same time on a server farm.
|
||||
self.minutes = [ord(settings.SECRET_KEY[-1]) % 60]
|
||||
|
||||
def cron_worker(publisher, now):
|
||||
try:
|
||||
|
|
|
@ -740,8 +740,8 @@ class QommonPublisher(Publisher, object):
|
|||
def register_cronjobs(cls):
|
||||
cls.register_cronjob(CronJob(cls.clean_sessions, minutes=range(0, 60, 5)))
|
||||
cls.register_cronjob(CronJob(cls.clean_nonces, minutes=range(0, 60, 5)))
|
||||
cls.register_cronjob(CronJob(cls.clean_afterjobs, minutes=[random.randint(0, 59)]))
|
||||
cls.register_cronjob(CronJob(cls.clean_tempfiles, minutes=[random.randint(0, 59)]))
|
||||
cls.register_cronjob(CronJob(cls.clean_afterjobs, hourly=True))
|
||||
cls.register_cronjob(CronJob(cls.clean_tempfiles, hourly=True))
|
||||
|
||||
register_tld_names = False
|
||||
|
||||
|
|
Loading…
Reference in New Issue