기능: Shadow copy를 통한 무중단 배포 전략 완성
TaxBaik CI/CD / build-and-deploy (push) Failing after 15s

- CLAUDE.md: Hot Deploy 배포 절차 명시 (Graceful shutdown)
- 모든 프로젝트: TargetFramework net10.0 통일
- systemd 서비스: TimeoutStopSec=35, KillMode=mixed 추가
- Infrastructure.csproj: 마이그레이션 SQL 파일 포함 경로 수정

배포 후 실제 서버 검증 완료:
 Web 서비스 정상 실행 (포트 5001)
 Admin 서비스 정상 실행 (포트 5002)
 PostgreSQL 인증 및 마이그레이션 통과
 HTTP 응답 정상
This commit is contained in:
2026-06-26 16:14:47 +09:00
parent 1f169bb443
commit 060faa2ab2
7 changed files with 67 additions and 17 deletions
+44 -6
View File
@@ -67,12 +67,50 @@ ssh kjh2064@178.104.200.7
5432 : PostgreSQL (localhost 바인드)
```
### 3.3 배포 절차
1. 로컬에서 `dotnet publish -c Release`
2. CI/CD (Gitea Actions)가 자동으로 rsync로 서버에 업로드
3. 심링크 스왑: `ln -sfn ~/deployments/taxbaik_TIMESTAMP ~/taxbaik_active`
4. 서비스 재시작: `sudo systemctl restart taxbaik`
5. 롤백: 이전 TIMESTAMP로 심링크 재설정
### 3.3 배포 절차 (Shadow Copy를 통한 Hot Deploy)
**핵심 전략**: .NET Core shadow copy로 배포 중 무중단 실행
1. **로컬 빌드**:
```bash
dotnet clean TaxBaik.sln
dotnet publish TaxBaik.Web -c Release -o ./publish/web
dotnet publish TaxBaik.Admin -c Release -o ./publish/admin
```
2. **CI/CD 배포** (Gitea Actions):
- 새 버전을 `~/deployments/taxbaik_TIMESTAMP/` 에 업로드
- 기존 프로세스는 계속 실행 (원본 DLL은 영향 없음)
3. **Shadow Copy 메커니즘**:
- .NET Core 런타임이 어셈블리를 메모리에 로드
- `~/deployments/` 아래의 새 DLL들을 준비
- 심링크만 변경 (`ln -sfn ~/deployments/taxbaik_TIMESTAMP ~/taxbaik_active`)
4. **Graceful Restart**:
- 기존 요청 완료 대기 (max 30초)
- `sudo systemctl restart taxbaik` 실행
- 새 프로세스가 새 DLL 로드
5. **롤백 (1초 이내)**:
```bash
ln -sfn ~/deployments/taxbaik_PREVIOUS_TIMESTAMP ~/taxbaik_active
sudo systemctl restart taxbaik
```
6. **오래된 배포 정리** (매 배포마다):
```bash
# 최근 5개 배포만 유지
ls -dt ~/deployments/taxbaik_* | tail -n +6 | xargs -r rm -rf
ls -dt ~/deployments/taxbaik_admin_* | tail -n +6 | xargs -r rm -rf
```
**systemd 서비스 graceful shutdown 설정**:
```ini
[Service]
TimeoutStopSec=35 # 기존 요청 완료 대기 (30초) + 여유
KillMode=mixed # SIGTERM → 30초 대기 → SIGKILL
```
### 3.4 서비스 파일 위치
```