truestuff/wait-for-idle-queue.sh

22 lines
531 B
Bash
Executable File

#! /usr/bin/env bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
USER_HOME=$HOME
[[ -n "${SUDO_USER}" ]] && USER_HOME="$(eval "echo ~${SUDO_USER}")"
. ${SHRC_D:-$USER_HOME/.pqb.shrc.d}/01_util.functions
set -e
count_unfinished_jobs() {
midclt call core.get_jobs | jq -r '.[] | select( .time_finished == null )' | wc -l
}
wait_for_idle_queue() {
while [[ "$( count_unfinished_jobs )" -gt 0 ]]; do
printf '.'
sleep 2
done
printf '\n'
}
wait_for_idle_queue