Added retry-loop to init script
parent
d3da212ecc
commit
18e48a2ba1
|
|
@ -10,6 +10,57 @@ HTML_HOME="/html"
|
|||
BRANCHES_FOLDER="/html/branches"
|
||||
DADI_STAGING_REPOSITORY="git_dadi-staging:AG-IT/KlDaDiSeite.git"
|
||||
|
||||
MAX_RETRY_ATTEMPTS=${INIT_RETRY_ATTEMPTS:--1}
|
||||
RETRY_DELAY=${INIT_RETRY_DELAY:-2}
|
||||
|
||||
#
|
||||
# Funktion: Warte bis Git-Repository erreichbar ist
|
||||
#
|
||||
wait_for_git_repository() {
|
||||
local attempt=0
|
||||
local unlimited=false
|
||||
|
||||
# Prüfe ob unbegrenzte Retries gewünscht sind
|
||||
if [ $MAX_RETRY_ATTEMPTS -lt 0 ]; then
|
||||
unlimited=true
|
||||
echo "Checking Git repository availability (unlimited retries)..."
|
||||
else
|
||||
echo "Checking Git repository availability (max $MAX_RETRY_ATTEMPTS attempts)..."
|
||||
fi
|
||||
|
||||
while true; do
|
||||
if git ls-remote --heads "$DADI_STAGING_REPOSITORY" &>/dev/null; then
|
||||
echo "✓ Git repository is reachable!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
|
||||
if [ "$unlimited" = true ]; then
|
||||
echo "⏳ Waiting for Git repository... (attempt $attempt)"
|
||||
else
|
||||
echo "⏳ Waiting for Git repository... (attempt $attempt/$MAX_RETRY_ATTEMPTS)"
|
||||
|
||||
# Abbruch bei Erreichen des Limits
|
||||
if [ $attempt -ge $MAX_RETRY_ATTEMPTS ]; then
|
||||
echo "✗ Error: Could not reach Git repository after $MAX_RETRY_ATTEMPTS attempts"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep $RETRY_DELAY
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# Warte auf Git-Repository
|
||||
#
|
||||
if ! wait_for_git_repository; then
|
||||
echo "Initialization failed. Service will continue but branches won't be initialized."
|
||||
echo "You may need to manually trigger initialization or restart the service."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Remove all branch folders
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue