From a27a553e0a9782eda6023ec0b8b1055757bb511f Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 9 Dec 2020 15:11:07 +0100 Subject: [PATCH] feat(jobs): queue by jobctl priority --- src/Jobs.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Jobs.hs b/src/Jobs.hs index f667d0edb..cdcf5d3d7 100644 --- a/src/Jobs.hs +++ b/src/Jobs.hs @@ -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 )