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)"