1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-23 08:12:41 +00:00

FIX: Fix for startup errors on clean installs referencing scheduler variables

This commit is contained in:
evilhero 2017-11-25 20:03:43 -05:00
parent 05a3c49c65
commit ea34294006
3 changed files with 27 additions and 10 deletions

View file

@ -358,7 +358,13 @@ def start():
if _INITIALIZED:
#load up the previous runs from the job sql table so we know stuff...
helpers.job_management()
monitors = helpers.job_management()
SCHED_WEEKLY_LAST = monitors['weekly']
SCHED_SEARCH_LAST = monitors['search']
SCHED_UPDATER_LAST = monitors['dbupdater']
SCHED_MONITOR_LAST = monitors['monitor']
SCHED_VERSION_LAST = monitors['version']
SCHED_RSS_LAST = monitors['rss']
# Start our scheduled background tasks
SCHED.add_job(func=updater.dbUpdate, id='dbupdater', name='DB Updater', args=[None,None,True], trigger=IntervalTrigger(hours=0, minutes=5, timezone='UTC'))
@ -420,19 +426,20 @@ def start():
except:
SCHED_WEEKLY_LAST = None
weektimestamp = helpers.utctimestamp()
if SCHED_WEEKLY_LAST is not None:
weekly_timestamp = float(SCHED_WEEKLY_LAST)
else:
weekly_timestamp = helpers.utctimestamp() + weekly_interval
weekly_timestamp = weektimestamp + weekly_interval
ws = weeklypullit.Weekly()
duration_diff = (helpers.utctimestamp() - weekly_timestamp)/60
duration_diff = (weektimestamp - weekly_timestamp)/60
if duration_diff >= weekly_interval/60:
logger.info('[WEEKLY] Weekly Pull-Update initializing immediately as it has been %s hours since the last run' % (duration_diff/60))
if abs(duration_diff) >= weekly_interval/60:
logger.info('[WEEKLY] Weekly Pull-Update initializing immediately as it has been %s hours since the last run' % abs(duration_diff/60))
SCHED.add_job(func=ws.run, id='weekly', name='Weekly Pullist', next_run_time=datetime.datetime.utcnow(), trigger=IntervalTrigger(hours=weektimer, minutes=0, timezone='UTC'))
else:
weekly_diff = datetime.datetime.utcfromtimestamp(helpers.utctimestamp() + (weekly_interval - (duration_diff * 60)))
weekly_diff = datetime.datetime.utcfromtimestamp(weektimestamp + (weekly_interval - (duration_diff * 60)))
logger.fdebug('[WEEKLY] Scheduling next run for @ %s every %s hours' % (weekly_diff, weektimer))
SCHED.add_job(func=ws.run, id='weekly', name='Weekly Pullist', next_run_time=weekly_diff, trigger=IntervalTrigger(hours=weektimer, minutes=0, timezone='UTC'))

View file

@ -3145,6 +3145,13 @@ def job_management(write=False, job=None, last_run_completed=None, current_run=N
monitor_newstatus = ji['status']
monitor_nextrun = ji['next_run_timestamp']
monitors = {'weekly': mylar.SCHED_WEEKLY_LAST,
'monitor': mylar.SCHED_MONITOR_LAST,
'search': mylar.SCHED_SEARCH_LAST,
'dbupdater': mylar.SCHED_DBUPDATE_LAST,
'version': mylar.SCHED_VERSION_LAST,
'rss': mylar.SCHED_RSS_LAST}
#this is for initial startup
for jb in mylar.SCHED.get_jobs():
#logger.fdebug('jb: %s' % jb)
@ -3195,8 +3202,10 @@ def job_management(write=False, job=None, last_run_completed=None, current_run=N
'status': newstatus})
if not write:
#logger.info('jobresults: %s' % jobresults)
return jobresults
if len(jobresults) == 0:
return monitors
else:
return jobresults
else:
if job is None:
for x in jobresults:

View file

@ -340,9 +340,10 @@ def dbUpdate(ComicIDList=None, calledfrom=None, sched=False):
if sched is False:
time.sleep(15) #pause for 15 secs so dont hammer CV and get 500 error
else:
helpers.job_management(write=True, job='DB Updater', last_run_completed=helpers.utctimestamp(), status='Waiting')
mylar.UPDATER_STATUS = 'Waiting'
break
helpers.job_management(write=True, job='DB Updater', last_run_completed=helpers.utctimestamp(), status='Waiting')
mylar.UPDATER_STATUS = 'Waiting'
logger.info('Update complete')
def latest_update(ComicID, LatestIssue, LatestDate):