refactor: unify grouped execution order
This commit is contained in:
1 parent
3da799a526
commit
48ddc3e728
1 file changed
+36
-21
@@ -335,12 +335,30 @@ run_group() {
|
||||
fi
|
||||
|
||||
case "$action" in
|
||||
up | start) working_result="Starting"; success_result="Started" ;;
|
||||
restart) working_result="Restarting"; success_result="Restarted" ;;
|
||||
stop) working_result="Stopping"; success_result="Stopped" ;;
|
||||
down) working_result="Removing"; success_result="Removed" ;;
|
||||
pull) working_result="Pulling"; success_result="Pulled" ;;
|
||||
update) working_result="Updating"; success_result="Updated" ;;
|
||||
up | start)
|
||||
working_result="Starting"
|
||||
success_result="Started"
|
||||
;;
|
||||
restart)
|
||||
working_result="Restarting"
|
||||
success_result="Restarted"
|
||||
;;
|
||||
stop)
|
||||
working_result="Stopping"
|
||||
success_result="Stopped"
|
||||
;;
|
||||
down)
|
||||
working_result="Removing"
|
||||
success_result="Removed"
|
||||
;;
|
||||
pull)
|
||||
working_result="Pulling"
|
||||
success_result="Pulled"
|
||||
;;
|
||||
update)
|
||||
working_result="Updating"
|
||||
success_result="Updated"
|
||||
;;
|
||||
esac
|
||||
|
||||
while :; do
|
||||
@@ -438,6 +456,7 @@ collect_skipped_groups() {
|
||||
run_all_grouped() {
|
||||
local action="$1"
|
||||
local direction="forward"
|
||||
local start=0 end="${#GROUP_NAMES[@]}" step=1
|
||||
local i
|
||||
|
||||
RUN_SUCCESS=0
|
||||
@@ -448,23 +467,19 @@ run_all_grouped() {
|
||||
|
||||
if [[ "$action" == "stop" || "$action" == "down" ]]; then
|
||||
direction="reverse"
|
||||
for ((i = ${#GROUP_NAMES[@]} - 1; i >= 0; i--)); do
|
||||
if ! run_group "$i" "$action"; then
|
||||
collect_skipped_groups "$i" "$direction"
|
||||
print_run_summary
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
else
|
||||
for ((i = 0; i < ${#GROUP_NAMES[@]}; i++)); do
|
||||
if ! run_group "$i" "$action"; then
|
||||
collect_skipped_groups "$i" "$direction"
|
||||
print_run_summary
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
start=$((end - 1))
|
||||
end=-1
|
||||
step=-1
|
||||
fi
|
||||
|
||||
for ((i = start; i != end; i += step)); do
|
||||
if ! run_group "$i" "$action"; then
|
||||
collect_skipped_groups "$i" "$direction"
|
||||
print_run_summary
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
print_run_summary
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user