From 7a0f5a968f374739bd4aab9a85f30b5c69e8cf20 Mon Sep 17 00:00:00 2001 From: Thomas M Date: Sat, 5 Dec 2026 21:32:09 +0000 Subject: [PATCH] opencode/compose.yaml aktualisiert --- opencode/compose.yaml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/opencode/compose.yaml b/opencode/compose.yaml index a426da5..0f18797 100644 --- a/opencode/compose.yaml +++ b/opencode/compose.yaml @@ -13,8 +13,9 @@ services: - | command -v git >/dev/null 2>&1 || /sbin/apk add --no-cache git curl ca-certificates - # Background Git sync loop for /root/.config/opencode + # Busy-safe background Git sync loop for /root/.config/opencode ( + PENDING_RESTART=0 while true; do sleep 60 if [ -d /root/.config/opencode/.git ]; then @@ -24,13 +25,20 @@ services: REMOTE=$$(git rev-parse origin/main 2>/dev/null) if [ -n "$$REMOTE" ] && [ "$$LOCAL" != "$$REMOTE" ]; then CHANGED=$$(git diff --name-only "$$LOCAL" "$$REMOTE") - git pull --ff-only origin main -q - # Restart container only if opencode.jsonc changed - if echo "$$CHANGED" | grep -q "opencode.jsonc"; then - kill 1 + if git pull --ff-only origin main -q; then + if echo "$$CHANGED" | grep -q "opencode.jsonc"; then + PENDING_RESTART=1 + fi fi fi fi + + if [ "$$PENDING_RESTART" -eq 1 ]; then + STATUS=$$(curl -s -m 5 -u "$$OPENCODE_SERVER_USERNAME:$$OPENCODE_SERVER_PASSWORD" http://127.0.0 2>/dev/null) + if [ -n "$$STATUS" ] && ! echo "$$STATUS" | grep -qE '"(busy|running|retry)"'; then + kill 1 + fi + fi done ) &