Fix bare worktree submodule clone and host AI startup wait on deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Macbook
2026-07-23 12:58:06 +09:00
parent 9ea8540979
commit b23e96c412
3 changed files with 73 additions and 13 deletions
+28 -10
View File
@@ -50,22 +50,40 @@ chmod +x "$WORK_TREE/chatbotApp-chatbot2.0-agent/build.sh" 2>/dev/null || true
log "[Phase 1] stop-all-server.sh"
"$WORK_TREE/server-dev/stop-all-server.sh" --keep-caddy || true
log "[Phase 2] .env 준비"
ensure_worktree_git() {
local tree="$1"
local git_dir="$2"
if [[ ! -e "${tree}/.git" ]]; then
echo "gitdir: ${git_dir}" > "${tree}/.git"
log "work tree .git 연결: ${tree}"
fi
}
sync_worktree_submodules() {
local tree="$1"
ensure_worktree_git "${tree}" "${GIT_DIR}"
if [[ -x "${tree}/git_fetch_all.sh" ]]; then
log "GitHub submodule 동기화 (git_fetch_all.sh --init)..."
"${tree}/git_fetch_all.sh" --init || log "[WARN] git_fetch_all 실패"
else
log "git submodule update --init --recursive"
git -C "${tree}" submodule sync --recursive 2>/dev/null || true
git -C "${tree}" submodule update --init --recursive || log "[WARN] submodule update 실패"
fi
}
log "[Phase 2] checkout + GitHub submodule"
git --work-tree="$WORK_TREE" --git-dir="$GIT_DIR" checkout -f "$BRANCH"
sync_worktree_submodules "$WORK_TREE"
log "[Phase 3] .env 준비"
ENV_FILE="$WORK_TREE/exAiChatBot-chatbot2.0-agent/.env"
if [[ ! -f "$ENV_FILE" ]]; then
cp "$WORK_TREE/server-dev/env.exdev-server.template" "$ENV_FILE"
log ".env 생성 (env.exdev-server.template)"
fi
log "[Phase 2.5] work tree checkout + GitHub submodule"
git --work-tree="$WORK_TREE" --git-dir="$GIT_DIR" checkout -f "$BRANCH"
if [[ -x "$WORK_TREE/git_fetch_all.sh" ]]; then
"$WORK_TREE/git_fetch_all.sh" --init || log "[WARN] git_fetch_all 실패"
else
git -C "$WORK_TREE" submodule update --init --recursive 2>/dev/null || true
fi
log "[Phase 3] start-all-server.sh (빌드 + 기동, push 생략)"
log "[Phase 4] start-all-server.sh (빌드 + 기동, push 생략)"
"$WORK_TREE/server-dev/start-all-server.sh" --skip-legacy-stop --no-pull --no-push
COMMIT="$(git --git-dir="$GIT_DIR" rev-parse --short HEAD 2>/dev/null || echo unknown)"
+13
View File
@@ -161,6 +161,9 @@ sync_source_from_git() {
fail "브랜치 없음: ${branch} (GIT_DIR=${GIT_DIR})"
fi
git --work-tree="${tree}" --git-dir="${GIT_DIR}" checkout -f "${branch}"
if [[ ! -e "${tree}/.git" ]]; then
echo "gitdir: ${GIT_DIR}" > "${tree}/.git"
fi
sync_github_submodules "${tree}" || true
local commit
commit="$(git --git-dir="${GIT_DIR}" rev-parse --short HEAD)"
@@ -252,6 +255,16 @@ ensure_host_ai() {
if host_ai_ready; then
return 0
fi
log "호스트 AI 기동 대기 (최대 120s)..."
local i=0
while (( i < 120 )); do
if host_ai_ready; then
log "✅ 호스트 AI 준비 완료"
return 0
fi
sleep 5
i=$((i + 5))
done
if curl -sf --max-time 3 "http://127.0.0.1:${LLM_PORT}/v1/models" >/dev/null 2>&1; then
log "⚠️ LLM만 응답 (Embed/Rerank 미기동) — degraded 모드로 계속"
return 0