Make the delay we wait for MinIO start configurable (#45)

* Make the delay we wait for MinIO start configurable

* fix: update after review
This commit is contained in:
Alexandre-P
2022-01-17 18:38:47 +01:00
committed by GitHub
parent ef0c01ac46
commit 21db075bfd
2 changed files with 48 additions and 1 deletions

View File

@@ -76,6 +76,52 @@ is_minio_running() {
fi
}
########################
# Check if MinIO is live
# Globals:
# MINIO_PID
# Arguments:
# None
# Returns:
# Boolean
########################
is_minio_live() {
local status_code
if [[ -z "${MINIO_PID:-}" ]]; then
false
else
if ! is_service_running "$MINIO_PID"; then
false
else
# We use cURL because we need to check the liveness before the client is configured
status_code=$(curl --write-out '%{http_code}' --silent --output /dev/null "${MINIO_SCHEME}://127.0.0.1:${MINIO_API_PORT_NUMBER}/minio/health/live")
if [[ "$status_code" = "200" ]]; then
true
else
false
fi
fi
fi
}
########################
# Wait for MinIO start
# Globals:
# MINIO_STARTUP_TIMEOUT
# Arguments:
# None
# Returns:
# None
########################
wait_for_minio() {
local waited_time
waited_time=0
while ! is_minio_live && [[ "$waited_time" -lt "$MINIO_STARTUP_TIMEOUT" ]]; do
sleep 5
waited_time=$((waited_time+5))
done
}
########################
# Start MinIO in background and wait until it's ready
# Globals:
@@ -111,7 +157,7 @@ minio_start_bg() {
"${exec}" "${args[@]}" >/dev/null 2>&1 &
fi
export MINIO_PID="$!"
sleep 10
wait_for_minio
}
########################

View File

@@ -66,6 +66,7 @@ export MINIO_SCHEME="${MINIO_SCHEME:-http}"
export MINIO_SKIP_CLIENT="${MINIO_SKIP_CLIENT:-no}"
export MINIO_DISTRIBUTED_MODE_ENABLED="${MINIO_DISTRIBUTED_MODE_ENABLED:-no}"
export MINIO_DEFAULT_BUCKETS="${MINIO_DEFAULT_BUCKETS:-}"
export MINIO_STARTUP_TIMEOUT=${MINIO_STARTUP_TIMEOUT:-10}
# MinIO security
export MINIO_FORCE_NEW_KEYS="${MINIO_FORCE_NEW_KEYS:-no}"