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
+32 -3
View File
@@ -52,10 +52,39 @@ if [[ ${#SUBMODULE_PATHS[@]} -eq 0 ]]; then
fi fi
if $INIT && ! $DRY_RUN; then if $INIT && ! $DRY_RUN; then
log "submodule init..." log "submodule init (direct clone)..."
git submodule update --init --recursive
fi fi
resolve_monorepo_git_dir() {
if [[ -n "${GIT_DIR:-}" && -d "${GIT_DIR}" ]]; then
echo "${GIT_DIR}"
elif git -C "${ROOT_DIR}" rev-parse --git-dir >/dev/null 2>&1; then
git -C "${ROOT_DIR}" rev-parse --git-dir
fi
}
submodule_pinned_sha() {
local path="$1"
local git_dir
git_dir="$(resolve_monorepo_git_dir || true)"
[[ -n "${git_dir}" ]] || return 0
git --git-dir="${git_dir}" ls-tree HEAD "${path}" 2>/dev/null | awk '{print $3}'
}
clone_submodule_repo() {
local path="$1" url="$2" branch="$3"
local target="${ROOT_DIR}/${path}"
local sha
sha="$(submodule_pinned_sha "${path}" || true)"
log " clone ${url} → ${path} (branch=${branch})"
rm -rf "${target}"
git clone --branch "${branch}" --single-branch "${url}" "${target}"
if [[ -n "${sha}" ]]; then
git -C "${target}" checkout "${sha}" 2>/dev/null || true
fi
}
restore_monorepo_overlays() { restore_monorepo_overlays() {
if [[ -f "${ROOT_DIR}/local-dev/docker-compose.rag.local.yml" ]]; then if [[ -f "${ROOT_DIR}/local-dev/docker-compose.rag.local.yml" ]]; then
cp "${ROOT_DIR}/local-dev/docker-compose.rag.local.yml" \ cp "${ROOT_DIR}/local-dev/docker-compose.rag.local.yml" \
@@ -86,7 +115,7 @@ fetch_one() {
return 0 return 0
fi fi
if $INIT; then if $INIT; then
git submodule update --init "${path}" clone_submodule_repo "${path}" "${url}" "${branch}"
else else
warn "${path} — submodule 미초기화. --init 옵션 사용" warn "${path} — submodule 미초기화. --init 옵션 사용"
return 1 return 1
+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" log "[Phase 1] stop-all-server.sh"
"$WORK_TREE/server-dev/stop-all-server.sh" --keep-caddy || true "$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" ENV_FILE="$WORK_TREE/exAiChatBot-chatbot2.0-agent/.env"
if [[ ! -f "$ENV_FILE" ]]; then if [[ ! -f "$ENV_FILE" ]]; then
cp "$WORK_TREE/server-dev/env.exdev-server.template" "$ENV_FILE" cp "$WORK_TREE/server-dev/env.exdev-server.template" "$ENV_FILE"
log ".env 생성 (env.exdev-server.template)" log ".env 생성 (env.exdev-server.template)"
fi fi
log "[Phase 2.5] work tree checkout + GitHub submodule" log "[Phase 4] start-all-server.sh (빌드 + 기동, push 생략)"
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 생략)"
"$WORK_TREE/server-dev/start-all-server.sh" --skip-legacy-stop --no-pull --no-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)" 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})" fail "브랜치 없음: ${branch} (GIT_DIR=${GIT_DIR})"
fi fi
git --work-tree="${tree}" --git-dir="${GIT_DIR}" checkout -f "${branch}" 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 sync_github_submodules "${tree}" || true
local commit local commit
commit="$(git --git-dir="${GIT_DIR}" rev-parse --short HEAD)" commit="$(git --git-dir="${GIT_DIR}" rev-parse --short HEAD)"
@@ -252,6 +255,16 @@ ensure_host_ai() {
if host_ai_ready; then if host_ai_ready; then
return 0 return 0
fi 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 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 모드로 계속" log "⚠️ LLM만 응답 (Embed/Rerank 미기동) — degraded 모드로 계속"
return 0 return 0