Add support for streaming and fixes few issues (see description) (#202)

This commit is contained in:
José Ulises Niño Rivera 2024-10-28 20:05:06 -04:00 committed by GitHub
parent 29ff8da60f
commit 662a840ac5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 2266 additions and 477 deletions

View file

@ -0,0 +1,33 @@
#!/bin/bash
log() {
timestamp=$(date +"%Y-%m-%d %H:%M:%S")
message="$*"
echo "$timestamp: $message"
}
wait_for_healthz() {
local healthz_url="$1"
local timeout_seconds="${2:-30}" # Default timeout of 30 seconds
local sleep_between="${3:-5}" # Default sleep of 5 seconds
local start_time=$(date +%s)
while true; do
local response_code=$(curl -s -o /dev/null -w "%{http_code}" "$healthz_url")
log "Healthz endpoint $healthz_url response code: $response_code"
if [[ "$response_code" -eq 200 ]]; then
log "Healthz endpoint is healthy. Proceeding..."
return 0
fi
local elapsed_time=$(( $(date +%s) - $start_time ))
if [[ $elapsed_time -ge $timeout_seconds ]]; then
log "Timeout reached. Healthz endpoint is still unhealthy. Exiting..."
return 1
fi
sleep $sleep_between
done
}