feat(jobs): queue by jobctl priority

This commit is contained in:
Gregor Kleen 2020-12-09 15:11:07 +01:00
parent 8873aed765
commit a27a553e0a

View File

@ -334,7 +334,7 @@ execCrontab = do
lastTimes <- State.get
now <- liftIO getCurrentTime
let currentCrontab' = sortOn cmpProj . flip map (HashMap.toList currentCrontab) $ \(job, cron) -> (job, getMax <$> HashMap.lookup job lastTimes, ) $ nextCronMatch appTZ (getMax <$> HashMap.lookup job lastTimes) (debouncingAcc settings job) now cron
where cmpProj (j, lT, qT) = (qT, lT, j)
where cmpProj (j, lT, qT) = (qT, Down $ prioritiseJob j, lT, j)
crontabTVar <- asks jobCurrentCrontab
atomically . writeTVar crontabTVar $ Just (now, currentCrontab')
$logDebugS "Crontab" . intercalate "\n" $ "Current crontab:" : map tshow currentCrontab'
@ -395,6 +395,7 @@ execCrontab = do
where
t = nextCronMatch appTZ (getMax <$> HashMap.lookup jobCtl lastTimes) (debouncingAcc settings jobCtl) now cron
cmpProj (j, qT) = ( qT
, Down $ prioritiseJob j
, getMax <$> HashMap.lookup j lastTimes
, j
)