From b2d1ca40d5bd1015a37cc243000b636eefc3d128 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Sun, 25 Aug 2019 04:31:18 +0200 Subject: Support parallel execution --- remote/lib/parameters.sh | 1 + remote/lib/report.sh | 1 + remote/lib/status.sh | 28 +++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 5 deletions(-) (limited to 'remote/lib') diff --git a/remote/lib/parameters.sh b/remote/lib/parameters.sh index 0714a68..8ff033e 100644 --- a/remote/lib/parameters.sh +++ b/remote/lib/parameters.sh @@ -2,6 +2,7 @@ timeout=2 fold=120 #palete='blue' +parallel=0 # Helpers diff --git a/remote/lib/report.sh b/remote/lib/report.sh index a5c16d4..d808cc2 100644 --- a/remote/lib/report.sh +++ b/remote/lib/report.sh @@ -8,6 +8,7 @@ function standart_report { report=$(cat<&12) } 12<&12 + if [ -n "$output" ]; then + flock -x $0 echo "${output}" >&12 + fi else print_status "x" for service in "$services"; do @@ -154,13 +156,15 @@ function check_service { important=$(grep "^\*" <<< $output) messages=$(grep -v "^\*" <<< $output) - [ -n "$output" ] && output="\n$(decorate "$service:$id" "cyan" "u")\n$(set_color white)$important\n$(reset_color)$messages\n" -} - + if [ -n "$output" ]; then + output="\n$(decorate "$service:$id" "cyan" "u")\n$(set_color white)$important\n$(reset_color)$messages\n" + flock -x $0 echo "${output}" >&12 + fi +} -function check { +function check__ { local args local title="$1" && shift read -ra args <<< "$1" && shift @@ -175,3 +179,17 @@ function check { done print_eol } + +function check_ { + # Buffer the output + local output=$(check__ "$@") + echo -e "$output" +} + +function check { + if [ $parallel -gt 0 ]; then + check_ "$@" & + else + check_ "$@" + fi +} -- cgit v1.2.3