possible feedback for cloneing hang
This commit is contained in:
+81
-8
@@ -73,7 +73,67 @@ fi
|
||||
|
||||
# Sync Add-On from git repository if BL_ADDON_REPO is set (only on reboot; only pulls when remote has updates)
|
||||
if [ -n "$BL_ADDON_REPO" ]; then
|
||||
echo "Syncing Add-On from git repository..."
|
||||
# Log HTTPS userinfo redacted (password/token); SSH URLs shown as-is
|
||||
bl_redact_git_remote_url() {
|
||||
case "$1" in
|
||||
http://*|https://*)
|
||||
echo "$1" | sed -E 's#(https?://)[^/@]+@#\1***@#'
|
||||
;;
|
||||
*)
|
||||
echo "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Pelican/Wings often use a pipe for the console: stdout is block-buffered, so plain echo can
|
||||
# appear "stuck" while git writes to stderr. Use stderr for all addon diagnostics.
|
||||
bl_addon_log() {
|
||||
printf '%s\n' "$*" >&2
|
||||
}
|
||||
|
||||
# Periodic lines while git runs (clone/fetch can look frozen in the panel otherwise)
|
||||
bl_git_with_heartbeat() {
|
||||
local label="$1"
|
||||
shift
|
||||
(
|
||||
while sleep 15; do
|
||||
printf '[BL_ADDON_REPO] %s — still running (%s). Slow network, huge repo, or waiting on auth/firewall.\n' \
|
||||
"$label" "$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >&2
|
||||
done
|
||||
) &
|
||||
local _hb=$!
|
||||
if command -v stdbuf >/dev/null 2>&1; then
|
||||
stdbuf -oL -eL "$@"
|
||||
else
|
||||
"$@"
|
||||
fi
|
||||
local _rc=$?
|
||||
kill "$_hb" 2>/dev/null
|
||||
wait "$_hb" 2>/dev/null
|
||||
return "$_rc"
|
||||
}
|
||||
|
||||
_repo_safe=$(bl_redact_git_remote_url "$BL_ADDON_REPO")
|
||||
bl_addon_log "Syncing Add-On from git repository..."
|
||||
bl_addon_log "[BL_ADDON_REPO] Remote (credentials redacted): ${_repo_safe}"
|
||||
if [ -n "$BL_ADDON_REPO_BRANCH" ]; then
|
||||
bl_addon_log "[BL_ADDON_REPO] Branch: ${BL_ADDON_REPO_BRANCH}"
|
||||
else
|
||||
bl_addon_log "[BL_ADDON_REPO] Branch: (repository default — not set)"
|
||||
fi
|
||||
bl_addon_log "[BL_ADDON_REPO] Target folder under Add-Ons: $(basename "$BL_ADDON_REPO" .git)"
|
||||
bl_addon_log "[BL_ADDON_REPO] If clone/fetch hangs or fails in the panel:"
|
||||
bl_addon_log " • No interactive login in Docker — private HTTPS repos usually need user + token IN the URL, e.g."
|
||||
bl_addon_log " https://YOUR_USER:YOUR_TOKEN@github.com/org/repo.git"
|
||||
bl_addon_log " (GitHub/GitLab: use a personal access token or deploy token, not your web password.)"
|
||||
bl_addon_log " • Or use SSH (git@host:org/repo.git) with a deploy key available inside the container."
|
||||
# Avoid indefinite hang waiting for a TTY password prompt (headless)
|
||||
export GIT_TERMINAL_PROMPT=0
|
||||
# Do not invoke a credential helper that might block without a TTY
|
||||
export GIT_ASKPASS=/bin/false
|
||||
|
||||
# Abort if transfer stalls (bytes/sec below limit for lowSpeedTime seconds)
|
||||
_git_slow=( -c "http.lowSpeedLimit=500" -c "http.lowSpeedTime=120" )
|
||||
|
||||
mkdir -p /home/container/Add-Ons
|
||||
cd /home/container/Add-Ons
|
||||
@@ -81,21 +141,34 @@ if [ -n "$BL_ADDON_REPO" ]; then
|
||||
repo_name=$(basename "$BL_ADDON_REPO" .git)
|
||||
|
||||
if [ -d "$repo_name/.git" ]; then
|
||||
bl_addon_log "[BL_ADDON_REPO] Existing clone at ${repo_name}/ — fetching..."
|
||||
cd "$repo_name"
|
||||
git fetch origin
|
||||
if ! bl_git_with_heartbeat "git fetch" git "${_git_slow[@]}" fetch --progress origin; then
|
||||
bl_addon_log "[BL_ADDON_REPO] ERROR: git fetch failed (auth, network, or stall). Remote (redacted): ${_repo_safe}"
|
||||
exit 1
|
||||
fi
|
||||
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
|
||||
behind=$(git rev-list HEAD.."${upstream:-origin/HEAD}" --count 2>/dev/null || echo 0)
|
||||
if [ "${behind:-0}" -gt 0 ]; then
|
||||
echo "Add-On has updates, pulling..."
|
||||
git pull --ff-only
|
||||
bl_addon_log "[BL_ADDON_REPO] Remote is ahead — pulling (--ff-only)..."
|
||||
if ! bl_git_with_heartbeat "git pull" git "${_git_slow[@]}" pull --ff-only --progress; then
|
||||
bl_addon_log "[BL_ADDON_REPO] ERROR: git pull failed. Remote (redacted): ${_repo_safe}"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Add-On is up to date."
|
||||
bl_addon_log "[BL_ADDON_REPO] Add-On is up to date (no new commits on tracked branch)."
|
||||
fi
|
||||
cd /home/container/Add-Ons
|
||||
else
|
||||
clone_opts=()
|
||||
[ -n "$BL_ADDON_REPO_BRANCH" ] && clone_opts=(-b "$BL_ADDON_REPO_BRANCH")
|
||||
git clone "${clone_opts[@]}" "$BL_ADDON_REPO"
|
||||
bl_addon_log "[BL_ADDON_REPO] No existing clone — starting git clone (this may take a while)..."
|
||||
clone_opts=(--progress --verbose)
|
||||
[ -n "$BL_ADDON_REPO_BRANCH" ] && clone_opts+=(-b "$BL_ADDON_REPO_BRANCH")
|
||||
if ! bl_git_with_heartbeat "git clone" git "${_git_slow[@]}" clone "${clone_opts[@]}" "$BL_ADDON_REPO"; then
|
||||
bl_addon_log "[BL_ADDON_REPO] ERROR: git clone failed. Check URL, auth, branch name, and network."
|
||||
bl_addon_log "[BL_ADDON_REPO] Remote used (redacted): ${_repo_safe}"
|
||||
exit 1
|
||||
fi
|
||||
bl_addon_log "[BL_ADDON_REPO] Clone finished successfully."
|
||||
fi
|
||||
|
||||
cd /home/container || exit 1
|
||||
|
||||
Reference in New Issue
Block a user