#!/usr/bin/env bash # Wait for an active one-month request, then start the full resumable range. set -u -o pipefail project_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) wait_pid=${1:-} log_dir="$project_root/outputs/logs" supervisor_log="$log_dir/ecmwf_baseline_supervisor.log" mkdir -p "$log_dir" if [[ "$wait_pid" =~ ^[1-9][0-9]*$ ]]; then while kill -0 "$wait_pid" 2>/dev/null; do command_line=$(tr '\0' ' ' <"/proc/$wait_pid/cmdline" 2>/dev/null || true) if [[ "$command_line" != *"dr_gcm.download_ecmwf_baseline --init 1981-01"* ]]; then printf '%s PID %s no longer matches initial request; continuing.\n' \ "$(date -Is)" "$wait_pid" >>"$supervisor_log" break fi printf '%s Waiting for initial request PID=%s.\n' \ "$(date -Is)" "$wait_pid" >>"$supervisor_log" sleep 60 done fi printf '%s Starting baseline range 1981-01..2020-12 with one worker.\n' \ "$(date -Is)" >>"$supervisor_log" exec bash "$project_root/scripts/download_ecmwf_baseline.sh" 1981-01 2020-12 1