Treating unfinished jobs + start_chart
This commit is contained in:
parent
b34716210e
commit
8320cec425
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -10,3 +10,4 @@ ${SCRIPT_DIR}/delete-all-catalogs.sh
|
|||
${SCRIPT_DIR}/wait-for-idle-queue.sh
|
||||
${SCRIPT_DIR}/stop-all-chrats.sh
|
||||
|
||||
cli -c 'system reboot'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#! /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/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
get_charts() {
|
||||
midclt call chart.release.query | jq -r "
|
||||
.[]
|
||||
| select( ${FILTER:-.status == \"STOPPED\"} )
|
||||
| .id
|
||||
" | sort -u
|
||||
}
|
||||
|
||||
get_charts_by_category() {
|
||||
local CATEGORY="${1}"
|
||||
midclt call chart.release.query | jq -r '
|
||||
.[]
|
||||
| select ( .chart_metadata.annotations."truecharts.org/catagories" == "- '"$CATEGORY"'\n" )
|
||||
| .id
|
||||
'
|
||||
}
|
||||
|
||||
start_chart_category() {
|
||||
local CATEGORY="${1}"
|
||||
printf "Starting apps by category: %s\n" "$CATEGORY"
|
||||
get_charts_by_category "$CATEGORY" | while read chart; do
|
||||
start_chart $chart
|
||||
done
|
||||
wait-for_idle_queue
|
||||
}
|
||||
|
||||
start_chart() {
|
||||
local CHART="${1}"
|
||||
printf 'Starting charts: %s... ' "$CHART"
|
||||
midclt call chart.release.scale "$CHART" '{"replica_count": 1}'
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
get_charts
|
||||
exit 2
|
||||
fi
|
||||
${SCRIPT_DIR}/wait-for-idle-queue.sh
|
||||
start_chart "${1}"
|
||||
${SCRIPT_DIR}/wait-for-idle-queue.sh
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
|
|
@ -2,12 +2,20 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
get_charts() {
|
||||
midclt call chart.release.query | jq -r '.[] | select( .status != "STOPPED" ) | .id'
|
||||
midclt call chart.release.query | jq -r '
|
||||
del(.[]
|
||||
| select( .status == "STOPPED" or (.id|inside(
|
||||
"traefik",
|
||||
"plex-pms"
|
||||
))
|
||||
))
|
||||
| .[].id
|
||||
'
|
||||
}
|
||||
|
||||
stop_chart() {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
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
|
||||
. ${SHRC_D:-$USER_HOME/.sz.shrc.d}/01_util.functions
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -11,12 +11,29 @@ count_unfinished_jobs() {
|
|||
}
|
||||
|
||||
wait_for_idle_queue() {
|
||||
local TIMEOUT="${1:-${TIMEOUT:-120}}" START="$(date +%s)"
|
||||
while [[ "$( count_unfinished_jobs )" -gt 0 ]]; do
|
||||
printf '.'
|
||||
|
||||
if (( TIMEOUT > 0 && ($(date +%s) - START) > TIMEOUT )); then
|
||||
printf 'TIMEOUT %s reached.\n' "$TIMEOUT" >&2
|
||||
printf '\n'
|
||||
return 1
|
||||
break;
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
done
|
||||
printf '\n'
|
||||
}
|
||||
|
||||
wait_for_idle_queue
|
||||
abort_unfinished_jobs() {
|
||||
midclt call core.get_jobs \
|
||||
| jq -r '.[] | select( .time_finished == null ) | .id ' \
|
||||
| xargs -rn1 midclt call core.job_abort
|
||||
}
|
||||
|
||||
wait_for_idle_queue || if [[ -z "$NO_AUTO_ABORT" ]]; then
|
||||
abort_unfinished_jobs
|
||||
fi
|
||||
|
Loading…
Reference in New Issue