diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2019-08-25 04:31:18 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2019-08-25 04:31:18 +0200 |
commit | b2d1ca40d5bd1015a37cc243000b636eefc3d128 (patch) | |
tree | 6feb2b563f6ad26afb91fbbf2d6eed2dce6713ab /remote/lib/status.sh | |
parent | c8c277200169dfadf88dd176e5c056967550e059 (diff) | |
download | conky-b2d1ca40d5bd1015a37cc243000b636eefc3d128.tar.gz conky-b2d1ca40d5bd1015a37cc243000b636eefc3d128.tar.bz2 conky-b2d1ca40d5bd1015a37cc243000b636eefc3d128.tar.xz conky-b2d1ca40d5bd1015a37cc243000b636eefc3d128.zip |
Support parallel execution
Diffstat (limited to 'remote/lib/status.sh')
-rw-r--r-- | remote/lib/status.sh | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/remote/lib/status.sh b/remote/lib/status.sh index 3c7fbec..644f20a 100644 --- a/remote/lib/status.sh +++ b/remote/lib/status.sh @@ -116,7 +116,9 @@ function check_server_status { print " ::: ${headers}" #report="$report<section>$output" - echo "${output}" >&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 +} |