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