- for file in "${ha_status_files[@]}"; do
- until [ -e "$ha_stop_file" ] ||
- [ -e "$file" ]; do
- if (($(date +%s) >= end)); then
- ha_info "Timed out while waiting for load status file $file"
- touch "$ha_fail_file"
- return 1
- fi
- ha_sleep 1 >/dev/null
- done
- done
+
+ #
+ # return immediately if ha_stop_file exists,
+ # all status_files not needed to be checked
+ #
+ for file in "${ha_status_files[@]}"; do
+ if [ -e "$ha_stop_file" ]; then
+ ha_info "$ha_stop_file found! Stop."
+ break
+ fi
+ #
+ # Wait status file created during ha_load_timeout.
+ # Existing file guarantees that some application
+ # is completed. If no status file was created
+ # this function guarantees that we allow
+ # applications to continue after/before
+ # failover/failback during ha_load_timeout time.
+ #
+ until [ -e "$file" ] || (($(date +%s) >= end)); do
+ #
+ # check ha_stop_file again, it could appear
+ # during ha_load_timeout
+ #
+ if [ -e "$ha_stop_file" ]; then
+ ha_info "$ha_stop_file found! Stop."
+ break
+ fi
+ ha_sleep 1 >/dev/null
+ done
+ done