From 727bd2b88279c2881b45328f0e7ae05f8313bb97 Mon Sep 17 00:00:00 2001 From: Lockszmith Date: Wed, 25 Oct 2023 10:13:14 -0400 Subject: [PATCH] Add option to ignore CRON jobs to get-queue --- get-queue.sh | 4 +++- wait-for-idle-queue.sh | 10 ++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/get-queue.sh b/get-queue.sh index 0163a75..66bdc17 100755 --- a/get-queue.sh +++ b/get-queue.sh @@ -1,3 +1,5 @@ #! /usr/bin/env bash -midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null ) | "\(.id) - \(.arguments[0])"' +IGNORE_CRON=${1:-$IGNORE_CRON} +CRON_TEST="${IGNORE_CRON:+and (.method != \"cronjob.run\")}" +midclt call core.get_jobs | jq -r '.[] | select( (.time_finished == null) '"${CRON_TEST}"' ) | "\(.id) - \(.arguments[0])"' diff --git a/wait-for-idle-queue.sh b/wait-for-idle-queue.sh index 5ba12a2..d8e35ca 100755 --- a/wait-for-idle-queue.sh +++ b/wait-for-idle-queue.sh @@ -6,8 +6,14 @@ USER_HOME=$HOME set -e -count_unfinished_jobs() { - midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l +IGNORE_CRON=${1:-${IGNORE_CRON}} + +count_unfinished_jobs() { + local TEST_CRON + TEST_CRON="${IGNORE_CRON:+" and .method != \"cronjob.run\""}" + midclt call core.get_jobs | jq -r ' + .[] | select( .time_finished == null '"$TEST_CRON"' ) + ' | wc -l } wait_for_idle_queue() {