2023-08-30 14:24:28 -05:00
|
|
|
function wait_for_string() {
|
|
|
|
local search_term="$1"
|
|
|
|
local filepath="$2"
|
|
|
|
local wait_time="${3:-2m}"
|
|
|
|
|
|
|
|
wait_file "$filepath" 60 || { echo "server log file missing: '$filepath'"; return 1; }
|
|
|
|
|
|
|
|
wait_str "$filepath" "$search_term" "$wait_time"
|
|
|
|
}
|
|
|
|
|
|
|
|
function wait_str() {
|
|
|
|
local filepath="$1"
|
|
|
|
local search_term="$2"
|
|
|
|
local wait_time="${3:-2m}"
|
|
|
|
|
2024-11-15 11:51:00 -05:00
|
|
|
(timeout $wait_time tail -F -n +1 "$filepath" &) | grep -q "$search_term" && return 0
|
2023-08-30 14:24:28 -05:00
|
|
|
|
|
|
|
echo "timeout of $wait_time reached. unable to find '$search_term' in '$filepath'"
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function wait_file() {
|
|
|
|
local file="$1"; shift
|
|
|
|
local wait_seconds="${1:-60}"; shift
|
|
|
|
|
|
|
|
until test $((wait_seconds--)) -eq 0 -o -f "$file" ; do sleep 1; done
|
|
|
|
}
|