- 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:
@@ -67,12 +67,50 @@ ssh kjh2064@178.104.200.7
|
|||||||
5432 : PostgreSQL (localhost 바인드)
|
5432 : PostgreSQL (localhost 바인드)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 3.3 배포 절차
|
### 3.3 배포 절차 (Shadow Copy를 통한 Hot Deploy)
|
||||||
1. 로컬에서 `dotnet publish -c Release`
|
|
||||||
2. CI/CD (Gitea Actions)가 자동으로 rsync로 서버에 업로드
|
**핵심 전략**: .NET Core shadow copy로 배포 중 무중단 실행
|
||||||
3. 심링크 스왑: `ln -sfn ~/deployments/taxbaik_TIMESTAMP ~/taxbaik_active`
|
|
||||||
4. 서비스 재시작: `sudo systemctl restart taxbaik`
|
1. **로컬 빌드**:
|
||||||
5. 롤백: 이전 TIMESTAMP로 심링크 재설정
|
```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 서비스 파일 위치
|
### 3.4 서비스 파일 위치
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="../../db/migrations/*.sql" LinkBase="Migrations" />
|
<EmbeddedResource Include="../db/migrations/*.sql" LinkBase="Migrations" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ Description=TaxBaik Admin Backoffice (.NET 8 Blazor Server)
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Type=simple
|
||||||
User=kjh2064
|
User=kjh2064
|
||||||
WorkingDirectory=/home/kjh2064/taxbaik_admin_active
|
WorkingDirectory=/home/kjh2064/taxbaik_admin_active
|
||||||
ExecStart=/usr/bin/dotnet TaxBaik.Admin.dll
|
ExecStart=/usr/bin/dotnet TaxBaik.Admin.dll
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=5
|
||||||
KillSignal=SIGINT
|
|
||||||
|
# Graceful Shutdown (Hot Deploy용)
|
||||||
|
TimeoutStopSec=35
|
||||||
|
KillMode=mixed
|
||||||
|
KillSignal=SIGTERM
|
||||||
|
|
||||||
SyslogIdentifier=taxbaik-admin
|
SyslogIdentifier=taxbaik-admin
|
||||||
Environment=ASPNETCORE_ENVIRONMENT=Production
|
Environment=ASPNETCORE_ENVIRONMENT=Production
|
||||||
Environment=ASPNETCORE_URLS=http://127.0.0.1:5002
|
Environment=ASPNETCORE_URLS=http://127.0.0.1:5002
|
||||||
|
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
||||||
# 아래 줄은 서버에서 직접 편집 (git에 커밋하지 않음)
|
# 아래 줄은 서버에서 직접 편집 (git에 커밋하지 않음)
|
||||||
# Environment=ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=CHANGE_ME
|
# Environment=ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=CHANGE_ME
|
||||||
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
@@ -3,18 +3,24 @@ Description=TaxBaik Public Website (.NET 8)
|
|||||||
After=network.target
|
After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
Type=simple
|
||||||
User=kjh2064
|
User=kjh2064
|
||||||
WorkingDirectory=/home/kjh2064/taxbaik_active
|
WorkingDirectory=/home/kjh2064/taxbaik_active
|
||||||
ExecStart=/usr/bin/dotnet TaxBaik.Web.dll
|
ExecStart=/usr/bin/dotnet TaxBaik.Web.dll
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=5
|
||||||
KillSignal=SIGINT
|
|
||||||
|
# Graceful Shutdown (Hot Deploy용)
|
||||||
|
TimeoutStopSec=35
|
||||||
|
KillMode=mixed
|
||||||
|
KillSignal=SIGTERM
|
||||||
|
|
||||||
SyslogIdentifier=taxbaik
|
SyslogIdentifier=taxbaik
|
||||||
Environment=ASPNETCORE_ENVIRONMENT=Production
|
Environment=ASPNETCORE_ENVIRONMENT=Production
|
||||||
Environment=ASPNETCORE_URLS=http://127.0.0.1:5001
|
Environment=ASPNETCORE_URLS=http://127.0.0.1:5001
|
||||||
|
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
||||||
# 아래 줄은 서버에서 직접 편집 (git에 커밋하지 않음)
|
# 아래 줄은 서버에서 직접 편집 (git에 커밋하지 않음)
|
||||||
# Environment=ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=CHANGE_ME
|
# Environment=ConnectionStrings__Default=Host=localhost;Database=taxbaikdb;Username=taxbaik;Password=CHANGE_ME
|
||||||
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
Reference in New Issue
Block a user