Compare commits
49 Commits
96383595df
...
feat/train
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d2a4049d3 | |||
| 0cbaf53e86 | |||
| 80fd2bda3e | |||
| fb647e5991 | |||
| 87575a62f7 | |||
| 246c11f8b0 | |||
| 2c1f9bdf5c | |||
| 5799f7dfb2 | |||
| 9f428e9572 | |||
| 904968a1be | |||
| 4b44be6a29 | |||
| f9f0662f8e | |||
| 7416327cc3 | |||
| da31bd9d99 | |||
| f3e5347335 | |||
| 7d5581f60c | |||
| b4428217ea | |||
| 8a63fdacdd | |||
| cb2e42143a | |||
| 997e85c0cc | |||
| 731ca59475 | |||
| fe6d37456d | |||
| 6c98a48a5d | |||
| 81b69caa99 | |||
| 7fce070686 | |||
| 8d83505ee7 | |||
| 0ff38b24d4 | |||
| 265813e6f7 | |||
| 8190a6e9c8 | |||
| 5c082f7c9d | |||
| 43d0e55cb7 | |||
| df3bedfbda | |||
| c26a48d07d | |||
| 1c7c213977 | |||
| 6583a45abd | |||
| b15f77d894 | |||
| 3bcd99f0db | |||
| 5513cd60a0 | |||
| 7b35d26a13 | |||
| d92ff88ef7 | |||
| bfcddd0327 | |||
| e193330f99 | |||
| 6c0184597d | |||
| 1e8a8d8dad | |||
| eb7680b952 | |||
| 2c357ebf27 | |||
| 0daaa1c8cb | |||
| e9f8bb37fa | |||
| f3c822587f |
443
DEPLOYMENT.md
Normal file
443
DEPLOYMENT.md
Normal file
@@ -0,0 +1,443 @@
|
||||
# KAMCO Train API - Production Deployment Guide
|
||||
|
||||
프로덕션 환경 배포 가이드
|
||||
|
||||
## 목차
|
||||
- [사전 요구사항](#사전-요구사항)
|
||||
- [초기 설정](#초기-설정)
|
||||
- [배포 순서](#배포-순서)
|
||||
- [개별 서비스 관리](#개별-서비스-관리)
|
||||
- [롤백 절차](#롤백-절차)
|
||||
- [모니터링 및 헬스체크](#모니터링-및-헬스체크)
|
||||
- [트러블슈팅](#트러블슈팅)
|
||||
|
||||
---
|
||||
|
||||
## 사전 요구사항
|
||||
|
||||
### 시스템 요구사항
|
||||
- Docker Engine 20.10+
|
||||
- Docker Compose 2.0+
|
||||
- 최소 메모리: 4GB
|
||||
- 디스크 공간: 20GB 이상
|
||||
|
||||
### 네트워크 요구사항
|
||||
- 도메인 설정:
|
||||
- `train-kamco.com` → 서버 IP (Web UI)
|
||||
- `api.train-kamco.com` → 서버 IP (API)
|
||||
- 포트:
|
||||
- 80 (HTTP)
|
||||
- 443 (HTTPS)
|
||||
- 8080 (API - internal)
|
||||
- 3002 (Web - internal)
|
||||
|
||||
### 필수 파일
|
||||
- SSL 인증서:
|
||||
- `nginx/ssl/train-kamco.com.crt`
|
||||
- `nginx/ssl/train-kamco.com.key`
|
||||
- 환경 설정:
|
||||
- `application-prod.yml` (API 설정)
|
||||
- `.env` 파일 (IMAGE_TAG 등)
|
||||
|
||||
---
|
||||
|
||||
## 초기 설정
|
||||
|
||||
### 1. Docker 네트워크 생성
|
||||
|
||||
```bash
|
||||
# kamco-cds 네트워크 생성 (최초 1회만)
|
||||
docker network create kamco-cds
|
||||
|
||||
# 네트워크 확인
|
||||
docker network ls | grep kamco-cds
|
||||
```
|
||||
|
||||
### 2. SSL 인증서 배치
|
||||
|
||||
```bash
|
||||
# 인증서 디렉토리 생성
|
||||
mkdir -p nginx/ssl
|
||||
|
||||
# 인증서 파일 복사
|
||||
cp /path/to/train-kamco.com.crt nginx/ssl/
|
||||
cp /path/to/train-kamco.com.key nginx/ssl/
|
||||
|
||||
# 권한 설정
|
||||
chmod 600 nginx/ssl/train-kamco.com.key
|
||||
chmod 644 nginx/ssl/train-kamco.com.crt
|
||||
```
|
||||
|
||||
### 3. 환경 변수 설정
|
||||
|
||||
```bash
|
||||
# .env 파일 생성
|
||||
cat > .env << EOF
|
||||
IMAGE_TAG=latest
|
||||
SPRING_PROFILES_ACTIVE=prod
|
||||
TZ=Asia/Seoul
|
||||
EOF
|
||||
```
|
||||
|
||||
### 4. 볼륨 디렉토리 생성
|
||||
|
||||
```bash
|
||||
# 데이터 디렉토리 생성
|
||||
mkdir -p ./app/model_output
|
||||
mkdir -p ./app/train_dataset
|
||||
|
||||
# 권한 설정
|
||||
chmod -R 755 ./app
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 배포 순서
|
||||
|
||||
### 전체 스택 초기 배포
|
||||
|
||||
**중요**: 반드시 아래 순서대로 실행해야 합니다.
|
||||
|
||||
```bash
|
||||
# 1. Nginx 시작
|
||||
docker-compose -f docker-compose-nginx.yml up -d
|
||||
|
||||
# 2. Nginx 상태 확인
|
||||
docker ps | grep kamco-train-nginx
|
||||
|
||||
# 3. API 서비스 시작
|
||||
docker-compose -f docker-compose-prod.yml up -d
|
||||
|
||||
# 4. API 헬스체크 대기 (최대 40초)
|
||||
sleep 40
|
||||
curl -f http://localhost:8080/monitor/health
|
||||
|
||||
# 5. Web 서비스 시작 (kamco-train-web 프로젝트에서)
|
||||
# cd ../kamco-train-web
|
||||
# docker-compose -f docker-compose-prod.yml up -d
|
||||
|
||||
# 6. 전체 상태 확인
|
||||
docker ps -a | grep kamco
|
||||
```
|
||||
|
||||
### 배포 검증
|
||||
|
||||
```bash
|
||||
# 서비스별 헬스체크
|
||||
curl -f http://localhost:8080/monitor/health # API (internal)
|
||||
curl -kf https://api.train-kamco.com/monitor/health # API (external)
|
||||
curl -kf https://train-kamco.com # Web (external)
|
||||
|
||||
# Nginx 설정 검증
|
||||
docker exec kamco-train-nginx nginx -t
|
||||
|
||||
# 로그 확인
|
||||
docker-compose -f docker-compose-nginx.yml logs --tail=50
|
||||
docker-compose -f docker-compose-prod.yml logs --tail=50
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 개별 서비스 관리
|
||||
|
||||
### Nginx 관리
|
||||
|
||||
```bash
|
||||
# 설정 변경 후 리로드 (다운타임 없음)
|
||||
docker exec kamco-train-nginx nginx -s reload
|
||||
|
||||
# 재시작
|
||||
docker-compose -f docker-compose-nginx.yml restart
|
||||
|
||||
# 로그 확인
|
||||
docker-compose -f docker-compose-nginx.yml logs -f
|
||||
|
||||
# 컨테이너 내부 접근
|
||||
docker exec -it kamco-train-nginx sh
|
||||
```
|
||||
|
||||
### API 서비스 관리
|
||||
|
||||
```bash
|
||||
# 재배포 (새 이미지 빌드)
|
||||
docker-compose -f docker-compose-prod.yml up -d --build
|
||||
|
||||
# 재시작 (이미지 변경 없이)
|
||||
docker-compose -f docker-compose-prod.yml restart
|
||||
|
||||
# 중지
|
||||
docker-compose -f docker-compose-prod.yml down
|
||||
|
||||
# 로그 확인
|
||||
docker-compose -f docker-compose-prod.yml logs -f kamco-train-api
|
||||
|
||||
# 컨테이너 내부 접근
|
||||
docker exec -it kamco-train-api bash
|
||||
```
|
||||
|
||||
### Web 서비스 관리
|
||||
|
||||
```bash
|
||||
# kamco-train-web 프로젝트에서 실행
|
||||
cd ../kamco-train-web
|
||||
|
||||
# 재배포
|
||||
docker-compose -f docker-compose-prod.yml up -d --build
|
||||
|
||||
# 재시작
|
||||
docker-compose -f docker-compose-prod.yml restart
|
||||
|
||||
# 로그 확인
|
||||
docker-compose -f docker-compose-prod.yml logs -f
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 롤백 절차
|
||||
|
||||
### 이미지 기반 롤백
|
||||
|
||||
```bash
|
||||
# 1. 사용 가능한 이미지 확인
|
||||
docker images | grep kamco-train-api
|
||||
|
||||
# 2. 이전 이미지 태그로 롤백
|
||||
export IMAGE_TAG=previous-commit-hash
|
||||
docker-compose -f docker-compose-prod.yml up -d
|
||||
|
||||
# 3. 헬스체크 확인
|
||||
curl -f http://localhost:8080/monitor/health
|
||||
```
|
||||
|
||||
### Git 기반 롤백
|
||||
|
||||
```bash
|
||||
# 1. 이전 커밋으로 체크아웃
|
||||
git log --oneline -10
|
||||
git checkout <previous-commit-hash>
|
||||
|
||||
# 2. 재빌드 및 배포
|
||||
docker-compose -f docker-compose-prod.yml up -d --build
|
||||
|
||||
# 3. 검증 후 브랜치 업데이트 (필요시)
|
||||
# git checkout develop
|
||||
# git reset --hard <previous-commit-hash>
|
||||
# git push -f origin develop
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 모니터링 및 헬스체크
|
||||
|
||||
### 헬스체크 엔드포인트
|
||||
|
||||
```bash
|
||||
# API 헬스체크
|
||||
curl http://localhost:8080/monitor/health
|
||||
curl http://localhost:8080/monitor/health/readiness
|
||||
curl http://localhost:8080/monitor/health/liveness
|
||||
|
||||
# Nginx를 통한 헬스체크
|
||||
curl -k https://api.train-kamco.com/monitor/health
|
||||
```
|
||||
|
||||
### 컨테이너 상태 모니터링
|
||||
|
||||
```bash
|
||||
# 모든 컨테이너 상태
|
||||
docker ps -a | grep kamco
|
||||
|
||||
# 리소스 사용량 실시간 모니터링
|
||||
docker stats kamco-train-nginx kamco-train-api
|
||||
|
||||
# 헬스체크 상태
|
||||
docker inspect kamco-train-api | grep -A 10 Health
|
||||
```
|
||||
|
||||
### 로그 모니터링
|
||||
|
||||
```bash
|
||||
# 실시간 로그 (모든 서비스)
|
||||
docker-compose -f docker-compose-nginx.yml logs -f &
|
||||
docker-compose -f docker-compose-prod.yml logs -f &
|
||||
|
||||
# 에러 로그만 필터링
|
||||
docker-compose -f docker-compose-prod.yml logs | grep -i error
|
||||
|
||||
# 최근 100줄
|
||||
docker-compose -f docker-compose-prod.yml logs --tail=100
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 트러블슈팅
|
||||
|
||||
### 1. Nginx 502 Bad Gateway
|
||||
|
||||
**원인**: API 서비스가 준비되지 않음
|
||||
|
||||
```bash
|
||||
# API 컨테이너 상태 확인
|
||||
docker ps | grep kamco-train-api
|
||||
|
||||
# API 로그 확인
|
||||
docker logs kamco-train-api --tail=100
|
||||
|
||||
# 네트워크 연결 확인
|
||||
docker network inspect kamco-cds | grep kamco-train-api
|
||||
|
||||
# 해결: API 재시작
|
||||
docker-compose -f docker-compose-prod.yml restart
|
||||
```
|
||||
|
||||
### 2. SSL 인증서 오류
|
||||
|
||||
**원인**: 인증서 파일 누락 또는 권한 문제
|
||||
|
||||
```bash
|
||||
# 인증서 파일 확인
|
||||
ls -la nginx/ssl/
|
||||
|
||||
# Nginx 설정 검증
|
||||
docker exec kamco-train-nginx nginx -t
|
||||
|
||||
# 해결: 인증서 재배치 및 권한 설정
|
||||
chmod 600 nginx/ssl/train-kamco.com.key
|
||||
chmod 644 nginx/ssl/train-kamco.com.crt
|
||||
docker-compose -f docker-compose-nginx.yml restart
|
||||
```
|
||||
|
||||
### 3. 컨테이너 시작 실패
|
||||
|
||||
**원인**: 포트 충돌, 볼륨 권한, 메모리 부족
|
||||
|
||||
```bash
|
||||
# 포트 사용 확인
|
||||
netstat -tulpn | grep -E '80|443|8080'
|
||||
|
||||
# 볼륨 권한 확인
|
||||
ls -la ./app/
|
||||
|
||||
# 메모리 사용량 확인
|
||||
free -h
|
||||
docker system df
|
||||
|
||||
# 해결: 충돌 프로세스 종료 또는 포트 변경
|
||||
# 메모리 정리
|
||||
docker system prune -a
|
||||
```
|
||||
|
||||
### 4. 네트워크 연결 문제
|
||||
|
||||
**원인**: kamco-cds 네트워크 미생성 또는 컨테이너 미연결
|
||||
|
||||
```bash
|
||||
# 네트워크 확인
|
||||
docker network ls | grep kamco-cds
|
||||
|
||||
# 네트워크 상세 정보
|
||||
docker network inspect kamco-cds
|
||||
|
||||
# 해결: 네트워크 생성
|
||||
docker network create kamco-cds
|
||||
|
||||
# 컨테이너를 네트워크에 연결
|
||||
docker network connect kamco-cds kamco-train-api
|
||||
docker network connect kamco-cds kamco-train-nginx
|
||||
```
|
||||
|
||||
### 5. 데이터베이스 연결 실패
|
||||
|
||||
**원인**: application-prod.yml의 DB 설정 오류
|
||||
|
||||
```bash
|
||||
# API 로그에서 DB 연결 에러 확인
|
||||
docker logs kamco-train-api | grep -i "connection"
|
||||
|
||||
# DB 호스트 연결 테스트
|
||||
docker exec kamco-train-api ping <db-host>
|
||||
|
||||
# 해결: application-prod.yml 수정 후 재배포
|
||||
vim src/main/resources/application-prod.yml
|
||||
docker-compose -f docker-compose-prod.yml up -d --build
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Jenkins CI/CD 연동
|
||||
|
||||
현재 프로젝트는 Jenkins 파이프라인으로 자동 배포됩니다.
|
||||
|
||||
### Jenkinsfile-dev 주요 단계
|
||||
|
||||
1. **Checkout**: develop 브랜치 체크아웃
|
||||
2. **Build**: `./gradlew clean build -x test`
|
||||
3. **Extract Commit**: IMAGE_TAG로 사용
|
||||
4. **Transfer**: 배포 서버로 파일 전송
|
||||
5. **Deploy**: Docker Compose 빌드 및 배포
|
||||
6. **Health Check**: 30초 대기 후 헬스체크
|
||||
7. **Cleanup**: 오래된 이미지 정리 (최신 5개 유지)
|
||||
|
||||
### 배포 서버 정보
|
||||
|
||||
- **서버**: 192.168.2.109
|
||||
- **사용자**: space
|
||||
- **배포 경로**: `/home/space/kamco-training-api`
|
||||
- **헬스체크**: `http://localhost:7200/monitor/health`
|
||||
|
||||
---
|
||||
|
||||
## 백업 및 복구
|
||||
|
||||
### 데이터 백업
|
||||
|
||||
```bash
|
||||
# 볼륨 데이터 백업
|
||||
tar -czf backup-$(date +%Y%m%d).tar.gz ./app/model_output ./app/train_dataset
|
||||
|
||||
# 설정 파일 백업
|
||||
tar -czf config-backup-$(date +%Y%m%d).tar.gz \
|
||||
nginx/nginx.conf \
|
||||
nginx/ssl/ \
|
||||
src/main/resources/application-prod.yml
|
||||
```
|
||||
|
||||
### 이미지 백업
|
||||
|
||||
```bash
|
||||
# 현재 이미지 저장
|
||||
docker save kamco-train-api:latest | gzip > kamco-train-api-latest.tar.gz
|
||||
|
||||
# 이미지 복구
|
||||
gunzip -c kamco-train-api-latest.tar.gz | docker load
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 보안 체크리스트
|
||||
|
||||
- [ ] SSL 인증서 유효기간 확인
|
||||
- [ ] nginx/ssl/ 디렉토리 권한 600
|
||||
- [ ] application-prod.yml에 DB 비밀번호 암호화
|
||||
- [ ] JWT secret key 환경변수로 관리
|
||||
- [ ] Docker 소켓 권한 최소화
|
||||
- [ ] 방화벽 규칙 설정 (80, 443만 외부 노출)
|
||||
- [ ] 정기 보안 업데이트 (docker images)
|
||||
|
||||
---
|
||||
|
||||
## 참고 문서
|
||||
|
||||
- [CLAUDE.md](./CLAUDE.md) - 프로젝트 개발 가이드
|
||||
- [README.md](./README.md) - 프로젝트 개요
|
||||
- [Jenkinsfile-dev](./Jenkinsfile-dev) - CI/CD 파이프라인
|
||||
- [nginx/nginx.conf](./nginx/nginx.conf) - Nginx 설정
|
||||
|
||||
---
|
||||
|
||||
## 연락처
|
||||
|
||||
문제 발생 시:
|
||||
1. 로그 수집: `docker-compose logs` 출력
|
||||
2. 시스템 정보: `docker ps -a`, `docker network ls`
|
||||
3. 이슈 리포트: GitHub Issues 또는 내부 이슈 트래커
|
||||
@@ -5,6 +5,13 @@ services:
|
||||
dockerfile: Dockerfile-dev
|
||||
image: kamco-cd-training-api:${IMAGE_TAG:-latest}
|
||||
container_name: kamco-cd-training-api
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities: [gpu]
|
||||
ports:
|
||||
- "7200:8080"
|
||||
environment:
|
||||
|
||||
28
docker-compose-nginx.yml
Normal file
28
docker-compose-nginx.yml
Normal file
@@ -0,0 +1,28 @@
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: kamco-train-nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/ssl:/etc/nginx/ssl:ro
|
||||
- nginx-logs:/var/log/nginx
|
||||
networks:
|
||||
- kamco-cds
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "--no-check-certificate", "https://localhost/monitor/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
networks:
|
||||
kamco-cds:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
nginx-logs:
|
||||
driver: local
|
||||
@@ -1,33 +1,17 @@
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: kamco-cd-nginx
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
- ./nginx/ssl:/etc/nginx/ssl:ro
|
||||
- nginx-logs:/var/log/nginx
|
||||
depends_on:
|
||||
kamco-changedetection-api:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- kamco-cds
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "--no-check-certificate", "https://localhost/monitor/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
|
||||
kamco-changedetection-api:
|
||||
kamco-train-api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: kamco-cd-training-api:${IMAGE_TAG:-latest}
|
||||
container_name: kamco-cd-training-api
|
||||
image: kamco-train-api:${IMAGE_TAG:-latest}
|
||||
container_name: kamco-train-api
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities: [gpu]
|
||||
expose:
|
||||
- "8080"
|
||||
environment:
|
||||
@@ -50,7 +34,3 @@ services:
|
||||
networks:
|
||||
kamco-cds:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
nginx-logs:
|
||||
driver: local
|
||||
|
||||
@@ -389,6 +389,23 @@ docker-compose -f docker-compose-prod.yml restart nginx
|
||||
sudo setenforce 0
|
||||
```
|
||||
|
||||
|
||||
### 2단계: 시스템 신뢰 폴더로 복사
|
||||
터미널을 열고 관리자 권한(sudo)을 사용해 인증서를 시스템 폴더로 복사합니다.
|
||||
|
||||
```
|
||||
sudo cp mycert.crt /etc/pki/ca-trust/source/anchors/
|
||||
```
|
||||
|
||||
### 3단계: 시스템 신뢰 목록 업데이트
|
||||
아래 명령어를 입력해 추가한 인증서를 시스템에 갱신시킵니다.
|
||||
|
||||
```
|
||||
sudo update-ca-trust
|
||||
```
|
||||
|
||||
|
||||
|
||||
## 참고 자료
|
||||
|
||||
- [OpenSSL Documentation](https://www.openssl.org/docs/)
|
||||
|
||||
@@ -22,7 +22,11 @@ http {
|
||||
|
||||
# Upstream 설정
|
||||
upstream api_backend {
|
||||
server kamco-changedetection-api:8080;
|
||||
server kamco-train-api:8080;
|
||||
}
|
||||
|
||||
upstream web_backend {
|
||||
server kamco-train-web:3002;
|
||||
}
|
||||
|
||||
# HTTP → HTTPS 리다이렉트 서버
|
||||
@@ -37,7 +41,7 @@ http {
|
||||
# HTTPS 서버 설정
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name api.train-kamco.com train-kamco.com;
|
||||
server_name api.train-kamco.com;
|
||||
|
||||
# SSL 인증서 설정 (사설 인증서 - 멀티 도메인)
|
||||
ssl_certificate /etc/nginx/ssl/train-kamco.com.crt;
|
||||
@@ -72,6 +76,11 @@ http {
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
|
||||
# 인증 헤더 및 쿠키 전달 (JWT 토큰 전달 보장)
|
||||
proxy_pass_request_headers on;
|
||||
proxy_set_header Cookie $http_cookie;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
|
||||
# 타임아웃 설정 (대용량 파일 업로드 지원)
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
@@ -90,4 +99,81 @@ http {
|
||||
access_log off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# HTTPS 서버 설정 - Next.js Web Application
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name train-kamco.com;
|
||||
|
||||
# SSL 인증서 설정 (사설 인증서 - 멀티 도메인)
|
||||
ssl_certificate /etc/nginx/ssl/train-kamco.com.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/train-kamco.com.key;
|
||||
|
||||
# SSL 프로토콜 및 암호화 설정
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384';
|
||||
ssl_prefer_server_ciphers off;
|
||||
|
||||
# SSL 세션 캐시
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_timeout 10m;
|
||||
|
||||
# HSTS (HTTP Strict Transport Security)
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
# 보안 헤더
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# API 프록시 설정 (Web에서 API 호출 시)
|
||||
location /api/ {
|
||||
proxy_pass http://api_backend/api/;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# 프록시 헤더 설정
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
|
||||
# 인증 헤더 및 쿠키 전달
|
||||
proxy_pass_request_headers on;
|
||||
proxy_set_header Cookie $http_cookie;
|
||||
|
||||
# 타임아웃 설정
|
||||
proxy_connect_timeout 300s;
|
||||
proxy_send_timeout 300s;
|
||||
proxy_read_timeout 300s;
|
||||
}
|
||||
|
||||
# 프록시 설정
|
||||
location / {
|
||||
proxy_pass http://web_backend;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
# 프록시 헤더 설정
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
|
||||
# Next.js WebSocket 지원을 위한 Upgrade 헤더
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# 타임아웃 설정
|
||||
proxy_connect_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
proxy_read_timeout 600s;
|
||||
|
||||
# 버퍼 설정
|
||||
proxy_buffering on;
|
||||
proxy_buffer_size 4k;
|
||||
proxy_buffers 8 4k;
|
||||
proxy_busy_buffers_size 8k;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.kamco.cd.training.common.dto;
|
||||
|
||||
public class MonitorDto {
|
||||
|
||||
public int cpu; // CPU 사용률 (%)
|
||||
public long[] memory; // "사용/전체"
|
||||
public int gpu; // 🔥 전체 GPU 평균 (%)
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.kamco.cd.training.common.service;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Log4j2
|
||||
public class GpuDmonReader {
|
||||
|
||||
// =========================
|
||||
// GPU 사용률 저장소
|
||||
// key: GPU index (0,1,2...)
|
||||
// value: 현재 GPU 사용률 (%)
|
||||
// ConcurrentHashMap → 멀티스레드 안전
|
||||
// =========================
|
||||
private final Map<Integer, Integer> gpuUtilMap = new ConcurrentHashMap<>();
|
||||
|
||||
// =========================
|
||||
// 외부 조회용
|
||||
// SystemMonitorService에서 호출
|
||||
// =========================
|
||||
public Map<Integer, Integer> getGpuUtilMap() {
|
||||
return gpuUtilMap;
|
||||
}
|
||||
|
||||
// =========================
|
||||
// Bean 초기화 시 실행
|
||||
// - 별도 스레드에서 GPU 모니터링 시작
|
||||
// - 메인 스레드 block 방지
|
||||
// =========================
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
|
||||
// nvidia-smi 없는 환경이면 GPU 모니터링 비활성화
|
||||
if (!isNvidiaAvailable()) {
|
||||
log.warn("nvidia-smi not found. GPU monitoring disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 데몬 스레드로 실행 (서버 종료 시 자동 종료)
|
||||
Thread t = new Thread(this::runLoop, "gpu-dmon-thread");
|
||||
t.setDaemon(true);
|
||||
t.start();
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 무한 루프
|
||||
// - dmon 실행
|
||||
// - 죽으면 자동 재시작
|
||||
// =========================
|
||||
private void runLoop() {
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
runDmon(); // GPU 사용률 수집 시작
|
||||
} catch (Exception e) {
|
||||
// dmon 프로세스 종료되면 여기로 들어옴
|
||||
log.warn("dmon restart: {}", e.getMessage());
|
||||
}
|
||||
|
||||
// 5초 대기 후 재시작
|
||||
sleep(5000);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// nvidia-smi dmon 실행
|
||||
// - GPU 사용률 스트리밍으로 계속 수신
|
||||
// =========================
|
||||
private void runDmon() throws Exception {
|
||||
|
||||
// -s u → GPU utilization만 출력
|
||||
ProcessBuilder pb = new ProcessBuilder("nvidia-smi", "dmon", "-s", "u");
|
||||
|
||||
// 프로세스 실행 후 stdout 읽기
|
||||
try (BufferedReader br =
|
||||
new BufferedReader(new InputStreamReader(pb.start().getInputStream()))) {
|
||||
|
||||
String line;
|
||||
|
||||
// dmon은 계속 출력됨 (스트리밍)
|
||||
while ((line = br.readLine()) != null) {
|
||||
|
||||
// 헤더 제거 (#로 시작)
|
||||
if (line.startsWith("#")) continue;
|
||||
|
||||
line = line.trim();
|
||||
if (line.isEmpty()) continue;
|
||||
|
||||
// 공백 기준 분리
|
||||
String[] parts = line.split("\\s+");
|
||||
|
||||
// 첫 번째 값이 GPU index인지 확인
|
||||
if (!parts[0].matches("\\d+")) continue;
|
||||
|
||||
int index = Integer.parseInt(parts[0]);
|
||||
|
||||
try {
|
||||
// 두 번째 값이 GPU 사용률 (sm)
|
||||
int util = Integer.parseInt(parts[1]);
|
||||
|
||||
// 최신 값 갱신
|
||||
gpuUtilMap.put(index, util);
|
||||
|
||||
} catch (Exception ignored) {
|
||||
// 파싱 실패 시 무시
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 여기까지 왔다는 건 dmon 프로세스 종료됨
|
||||
// → runLoop에서 재시작하도록 예외 발생
|
||||
throw new IllegalStateException("dmon stopped");
|
||||
}
|
||||
|
||||
// =========================
|
||||
// nvidia-smi 존재 여부 확인
|
||||
// =========================
|
||||
private boolean isNvidiaAvailable() {
|
||||
try {
|
||||
Process p = new ProcessBuilder("which", "nvidia-smi").start();
|
||||
return p.waitFor() == 0;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// sleep 유틸
|
||||
// =========================
|
||||
private void sleep(long ms) {
|
||||
try {
|
||||
Thread.sleep(ms);
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
package com.kamco.cd.training.common.service;
|
||||
|
||||
import com.kamco.cd.training.common.dto.MonitorDto;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Log4j2
|
||||
public class SystemMonitorService {
|
||||
|
||||
// =========================
|
||||
// CPU 이전값 (delta 계산용)
|
||||
// - /proc/stat은 누적값이기 때문에
|
||||
// - 이전 값과 비교해서 사용률 계산
|
||||
// =========================
|
||||
private long prevIdle = 0;
|
||||
private long prevTotal = 0;
|
||||
|
||||
// =========================
|
||||
// 최근 30초 히스토리
|
||||
// - CPU: 30개 (1초 * 30)
|
||||
// - GPU: GPU별 30개
|
||||
// =========================
|
||||
private final Deque<Double> cpuHistory = new ArrayDeque<>();
|
||||
|
||||
// key: GPU index
|
||||
// value: 최근 30개 사용률
|
||||
private final Map<Integer, Deque<Integer>> gpuHistory = new ConcurrentHashMap<>();
|
||||
|
||||
// =========================
|
||||
// GPU 데이터 제공 (dmon reader)
|
||||
// =========================
|
||||
private final GpuDmonReader gpuReader;
|
||||
|
||||
// =========================
|
||||
// 캐시 (API 응답용)
|
||||
// - 매 요청마다 계산하지 않기 위해 사용
|
||||
// - volatile → 멀티스레드 안전하게 최신값 유지
|
||||
// =========================
|
||||
private volatile MonitorDto cached = new MonitorDto();
|
||||
|
||||
// =========================
|
||||
// 1초마다 수집
|
||||
// =========================
|
||||
@Scheduled(fixedRate = 1000)
|
||||
public void collect() {
|
||||
try {
|
||||
|
||||
// =====================
|
||||
// 1. CPU 수집
|
||||
// =====================
|
||||
double cpu = readCpu();
|
||||
|
||||
cpuHistory.add(cpu);
|
||||
|
||||
// 30개 유지 (rolling window)
|
||||
if (cpuHistory.size() > 30) cpuHistory.poll();
|
||||
|
||||
// =====================
|
||||
// 2. GPU 수집
|
||||
// =====================
|
||||
Map<Integer, Integer> gpuMap = gpuReader.getGpuUtilMap();
|
||||
|
||||
for (Map.Entry<Integer, Integer> entry : gpuMap.entrySet()) {
|
||||
|
||||
int index = entry.getKey();
|
||||
int util = entry.getValue();
|
||||
|
||||
// GPU별 히스토리 생성 및 추가
|
||||
gpuHistory.computeIfAbsent(index, k -> new ArrayDeque<>()).add(util);
|
||||
|
||||
// 30개 유지
|
||||
Deque<Integer> q = gpuHistory.get(index);
|
||||
if (q.size() > 30) q.poll();
|
||||
}
|
||||
|
||||
// =====================
|
||||
// 3. 캐시 업데이트
|
||||
// =====================
|
||||
updateCache();
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("collect error", e);
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// CPU 사용률 계산
|
||||
// - /proc/stat 사용
|
||||
// - 이전값과의 차이로 계산 (delta 방식)
|
||||
// =========================
|
||||
private double readCpu() throws Exception {
|
||||
|
||||
if (!isLinux()) return 0;
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader("/proc/stat"))) {
|
||||
|
||||
String[] p = br.readLine().split("\\s+");
|
||||
|
||||
long user = Long.parseLong(p[1]);
|
||||
long nice = Long.parseLong(p[2]);
|
||||
long system = Long.parseLong(p[3]);
|
||||
long idle = Long.parseLong(p[4]);
|
||||
long iowait = Long.parseLong(p[5]);
|
||||
long irq = Long.parseLong(p[6]);
|
||||
long softirq = Long.parseLong(p[7]);
|
||||
|
||||
long total = user + nice + system + idle + iowait + irq + softirq;
|
||||
long idleAll = idle + iowait;
|
||||
|
||||
// 최초 실행 시 기준값만 저장
|
||||
if (prevTotal == 0) {
|
||||
prevTotal = total;
|
||||
prevIdle = idleAll;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long totalDiff = total - prevTotal;
|
||||
long idleDiff = idleAll - prevIdle;
|
||||
|
||||
prevTotal = total;
|
||||
prevIdle = idleAll;
|
||||
|
||||
if (totalDiff == 0) return 0;
|
||||
|
||||
// CPU 사용률 (%)
|
||||
return (1.0 - (double) idleDiff / totalDiff) * 100;
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// Linux 환경 체크
|
||||
// =========================
|
||||
private boolean isLinux() {
|
||||
return System.getProperty("os.name").toLowerCase().contains("linux");
|
||||
}
|
||||
|
||||
// =========================
|
||||
// Memory 조회 (/proc/meminfo)
|
||||
// - OS 값 그대로 사용 (kB)
|
||||
// - [사용량, 전체]
|
||||
// =========================
|
||||
private long[] readMemory() throws Exception {
|
||||
|
||||
if (!isLinux()) return new long[] {0, 0};
|
||||
|
||||
try (BufferedReader br = new BufferedReader(new FileReader("/proc/meminfo"))) {
|
||||
|
||||
long total = 0;
|
||||
long available = 0;
|
||||
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.startsWith("MemTotal")) {
|
||||
total = Long.parseLong(line.replaceAll("\\D+", ""));
|
||||
} else if (line.startsWith("MemAvailable")) {
|
||||
available = Long.parseLong(line.replaceAll("\\D+", ""));
|
||||
}
|
||||
}
|
||||
|
||||
long used = total - available;
|
||||
|
||||
return new long[] {used, total};
|
||||
}
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 캐시 업데이트
|
||||
// - CPU: 30초 평균
|
||||
// - GPU: 전체 샘플 평균
|
||||
// - Memory: 현재값
|
||||
// =========================
|
||||
private void updateCache() throws Exception {
|
||||
|
||||
MonitorDto dto = new MonitorDto();
|
||||
|
||||
// =====================
|
||||
// CPU 평균 (30초)
|
||||
// =====================
|
||||
dto.cpu = (int) cpuHistory.stream().mapToDouble(Double::doubleValue).average().orElse(0);
|
||||
|
||||
// =====================
|
||||
// Memory (kB 그대로)
|
||||
// =====================
|
||||
dto.memory = readMemory();
|
||||
|
||||
// =====================
|
||||
// GPU 평균 (🔥 전체 샘플 기준)
|
||||
// =====================
|
||||
int sum = 0;
|
||||
int count = 0;
|
||||
|
||||
for (Deque<Integer> q : gpuHistory.values()) {
|
||||
for (int v : q) {
|
||||
sum += v;
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
dto.gpu = (count == 0) ? 0 : sum / count;
|
||||
|
||||
// =====================
|
||||
// 캐시 교체 (atomic)
|
||||
// =====================
|
||||
this.cached = dto;
|
||||
}
|
||||
|
||||
// =========================
|
||||
// 외부 조회
|
||||
// - Controller에서 호출
|
||||
// =========================
|
||||
public MonitorDto get() {
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
@@ -719,18 +719,26 @@ public class FIleChecker {
|
||||
public static void unzip(String fileName, String destDirectory) throws IOException {
|
||||
String zipFilePath = destDirectory + File.separator + fileName;
|
||||
|
||||
log.info("fileName : {}", fileName);
|
||||
log.info("destDirectory : {}", destDirectory);
|
||||
log.info("zipFilePath : {}", zipFilePath);
|
||||
// zip 이름으로 폴더 생성 (확장자 제거)
|
||||
String folderName =
|
||||
fileName.endsWith(".zip") ? fileName.substring(0, fileName.length() - 4) : fileName;
|
||||
log.info("folderName : {}", folderName);
|
||||
|
||||
File destDir = new File(destDirectory, folderName);
|
||||
log.info("destDir : {}", destDir);
|
||||
|
||||
// 동일 폴더가 이미 있으면 삭제
|
||||
log.info("111 destDir.exists() : {}", destDir.exists());
|
||||
if (destDir.exists()) {
|
||||
deleteDirectoryRecursively(destDir.toPath());
|
||||
}
|
||||
|
||||
log.info("222 destDir.exists() : {}", destDir.exists());
|
||||
if (!destDir.exists()) {
|
||||
log.info("mkdirs : {}", destDir.exists());
|
||||
destDir.mkdirs();
|
||||
}
|
||||
|
||||
|
||||
@@ -104,15 +104,19 @@ public class SecurityConfig {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
/** CORS 설정 */
|
||||
/** CORS 설정 - application.yml에서 환경별로 관리 */
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
CorsConfiguration config = new CorsConfiguration(); // CORS 객체 생성
|
||||
|
||||
// application.yml에서 환경별로 설정된 도메인 사용
|
||||
config.setAllowedOriginPatterns(List.of("*")); // 도메인 허용
|
||||
|
||||
config.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
|
||||
config.setAllowedHeaders(List.of("*")); // 헤더요청 Authorization, Content-Type, X-Custom-Header
|
||||
config.setAllowCredentials(true); // 쿠키, Authorization 헤더, Bearer Token 등 자격증명 포함 요청을 허용할지 설정
|
||||
config.setExposedHeaders(List.of("Content-Disposition"));
|
||||
config.setExposedHeaders(List.of("Content-Disposition", "Authorization"));
|
||||
config.setMaxAge(3600L); // Preflight 요청 캐시 (1시간)
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
/** "/**" → 모든 API 경로에 대해 이 CORS 규칙을 적용 /api/** 같이 특정 경로만 지정 가능. */
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StartupLogger {
|
||||
"""
|
||||
|
||||
╔════════════════════════════════════════════════════════════════════════════════╗
|
||||
║ 🚀 APPLICATION STARTUP INFORMATION ║
|
||||
║ 🚀 APPLICATION STARTUP INFORMATION 2 ║
|
||||
╠════════════════════════════════════════════════════════════════════════════════╣
|
||||
║ PROFILE CONFIGURATION ║
|
||||
╠────────────────────────────────────────────────────────────────────────────────╣
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.kamco.cd.training.model;
|
||||
|
||||
import com.kamco.cd.training.common.dto.MonitorDto;
|
||||
import com.kamco.cd.training.common.service.SystemMonitorService;
|
||||
import com.kamco.cd.training.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetDto;
|
||||
import com.kamco.cd.training.dataset.dto.DatasetDto.DatasetReq;
|
||||
@@ -40,6 +42,7 @@ public class ModelTrainMngApiController {
|
||||
private final ModelTrainMngService modelTrainMngService;
|
||||
private final ModelTrainMetricsJobService modelTrainMetricsJobService;
|
||||
private final ModelTestMetricsJobService modelTestMetricsJobService;
|
||||
private final SystemMonitorService systemMonitorService;
|
||||
|
||||
@Operation(summary = "모델학습 목록 조회", description = "모델학습 목록 조회 API")
|
||||
@ApiResponses(
|
||||
@@ -214,4 +217,22 @@ public class ModelTrainMngApiController {
|
||||
modelTestMetricsJobService.findTestValidMetricCsvFiles();
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@Operation(summary = "학습서버 시스템 사용율 조회", description = "cpu, gpu, memory 사용율 조회")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Long.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/monitor")
|
||||
public ApiResponseDto<MonitorDto> getSystem() throws IOException {
|
||||
return ApiResponseDto.ok(systemMonitorService.get());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ public class ModelTrainMngCoreService {
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.STOPPED.getId());
|
||||
master.setStep2State(TrainStatusType.STOPPED.getId());
|
||||
master.setStep1State(TrainStatusType.STOPPED.getId());
|
||||
master.setLastError(errorMessage);
|
||||
master.setUpdatedUid(userUtil.getId());
|
||||
master.setUpdatedDttm(ZonedDateTime.now());
|
||||
|
||||
@@ -98,6 +98,8 @@ public class DatasetRepositoryImpl implements DatasetRepositoryCustom {
|
||||
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
|
||||
builder.and(dataset.deleted.isFalse());
|
||||
|
||||
if (StringUtils.isNotBlank(req.getDataType()) && !"CURRENT".equals(req.getDataType())) {
|
||||
builder.and(dataset.dataType.eq(req.getDataType()));
|
||||
}
|
||||
@@ -249,6 +251,7 @@ public class DatasetRepositoryImpl implements DatasetRepositoryCustom {
|
||||
public List<SelectDataSet> getDatasetSelectG2G3List(DatasetReq req) {
|
||||
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
builder.and(dataset.deleted.isFalse());
|
||||
|
||||
NumberExpression<Long> selectedCnt = null;
|
||||
NumberExpression<Long> wasteCnt =
|
||||
|
||||
@@ -46,10 +46,17 @@ public class DockerTrainService {
|
||||
@Value("${train.docker.shmSize:16g}")
|
||||
private String shmSize;
|
||||
|
||||
// data 경로 request,response 상위 폴더
|
||||
@Value("${train.docker.basePath}")
|
||||
private String basePath;
|
||||
|
||||
// IPC host 사용 여부
|
||||
@Value("${train.docker.ipcHost:true}")
|
||||
private boolean ipcHost;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
private final ModelTrainJobCoreService modelTrainJobCoreService;
|
||||
|
||||
/**
|
||||
@@ -254,7 +261,9 @@ public class DockerTrainService {
|
||||
|
||||
// 요청/결과 디렉토리 볼륨 마운트
|
||||
c.add("-v");
|
||||
c.add("/home/kcomu/data" + "/tmp:/data");
|
||||
c.add(basePath + ":" + basePath); // 심볼릭 링크와 연결되는 실제 파일 경로도 마운트를 해줘야 함
|
||||
c.add("-v");
|
||||
c.add(basePath + "/tmp:/data");
|
||||
c.add("-v");
|
||||
c.add(responseDir + ":/checkpoints");
|
||||
|
||||
@@ -273,8 +282,15 @@ public class DockerTrainService {
|
||||
addArg(c, "--output-folder", req.getOutputFolder());
|
||||
addArg(c, "--input-size", req.getInputSize());
|
||||
addArg(c, "--crop-size", req.getCropSize());
|
||||
addArg(c, "--batch-size", req.getBatchSize());
|
||||
addArg(c, "--gpu-ids", req.getGpuIds()); // null
|
||||
// addArg(c, "--batch-size", req.getBatchSize());
|
||||
// addArg(c, "--gpu-ids", req.getGpuIds()); // null
|
||||
if ("prod".equals(profile)) {
|
||||
addArg(c, "--batch-size", 2); // 학습서버 GPU 1개인 곳은 batch-size:2 까지만 가능
|
||||
addArg(c, "--gpus", "1"); // 학습서버 GPU 1개인 곳은 1이어야 함
|
||||
addArg(c, "--gpu-ids", "0"); // 학습서버 GPU 1개인 곳은 0이어야 함
|
||||
} else {
|
||||
addArg(c, "--batch-size", req.getBatchSize()); // 학습서버 GPU 1개인 곳은 batch-size:2 까지만 가능
|
||||
}
|
||||
addArg(c, "--lr", req.getLearningRate());
|
||||
addArg(c, "--backbone", req.getBackbone());
|
||||
addArg(c, "--epochs", req.getEpochs());
|
||||
@@ -440,11 +456,14 @@ public class DockerTrainService {
|
||||
c.add("--rm");
|
||||
c.add("--gpus");
|
||||
c.add("all");
|
||||
|
||||
c.add("--ipc=host");
|
||||
c.add("--shm-size=" + shmSize);
|
||||
|
||||
c.add("-v");
|
||||
c.add("/home/kcomu/data" + "/tmp:/data");
|
||||
c.add(basePath + ":" + basePath); // 심볼릭 링크와 연결되는 실제 파일 경로도 마운트를 해줘야 함
|
||||
c.add("-v");
|
||||
c.add(basePath + "/tmp:/data");
|
||||
|
||||
c.add("-v");
|
||||
c.add(responseDir + ":/checkpoints");
|
||||
|
||||
@@ -43,6 +43,7 @@ public class JobRecoveryOnStartupService {
|
||||
|
||||
private final ModelTrainJobCoreService modelTrainJobCoreService;
|
||||
private final ModelTrainMngCoreService modelTrainMngCoreService;
|
||||
private final ModelTrainMetricsJobService modelTrainMetricsJobService;
|
||||
|
||||
/**
|
||||
* Docker 컨테이너가 쓰는 response(산출물) 디렉토리의 "호스트 측" 베이스 경로. 예) /data/train/response
|
||||
@@ -95,32 +96,41 @@ public class JobRecoveryOnStartupService {
|
||||
modelTrainJobCoreService.markSuccess(job.getId(), 0);
|
||||
// model 상태 변경
|
||||
markStepSuccessByJobType(job);
|
||||
// 결과 csv 파일 정보 등록
|
||||
modelTrainMetricsJobService.findTrainValidMetricCsvFiles();
|
||||
|
||||
} else {
|
||||
// 3-3) 산출물이 부족하면 실패 처리(운영 정책에 따라 "유예"도 가능)
|
||||
|
||||
// 3-3) 산출물이 부족하면 중단처리
|
||||
// 산출물이 부족하면 "중단/보류"로 처리
|
||||
// 운영자가 재시작 할 수 있게 한다.
|
||||
log.warn(
|
||||
"[RECOVERY] outputs incomplete. mark FAILED. jobId={} reason={}",
|
||||
"[RECOVERY] outputs incomplete. mark PAUSED/STOP for restart. jobId={} reason={}",
|
||||
job.getId(),
|
||||
out.reason());
|
||||
|
||||
modelTrainJobCoreService.markFailed(
|
||||
job.getId(), -1, "SERVER_RESTART_CONTAINER_MISSING_OUTPUT_INCOMPLETE");
|
||||
// model 상태 변경
|
||||
markStepErrorByJobType(job, out.reason());
|
||||
Integer modelId = job.getModelId() == null ? null : Math.toIntExact(job.getModelId());
|
||||
|
||||
// PAUSED/STOP
|
||||
modelTrainJobCoreService.markPaused(
|
||||
job.getId(), modelId, "SERVER_RESTART_CONTAINER_MISSING_OUTPUT_INCOMPLETE");
|
||||
|
||||
// 모델도 에러가 아니라 STOP으로
|
||||
markStepStopByJobType(
|
||||
job, "SERVER_RESTART_CONTAINER_MISSING_OUTPUT_INCOMPLETE: " + out.reason());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// 4) 컨테이너는 존재하고, 아직 running=true
|
||||
// - 서버만 재기동됐고 컨테이너는 그대로 살아있는 케이스
|
||||
// - 실행중 docker 를 stop 하고 이어하기를 한다,
|
||||
// - 실행중 docker 를 kill 하고 이어하기를 한다,
|
||||
if (state.running()) {
|
||||
log.warn("[RECOVERY] container still running. force kill. container={}", containerName);
|
||||
|
||||
try {
|
||||
// ============================================================
|
||||
// 1) docker kill (SIGKILL) 바로 전송
|
||||
// - stop은 grace period가 있지만
|
||||
// - kill은 즉시 종료
|
||||
// ============================================================
|
||||
ProcessBuilder pb = new ProcessBuilder("docker", "kill", containerName);
|
||||
@@ -157,6 +167,7 @@ public class JobRecoveryOnStartupService {
|
||||
modelTrainJobCoreService.markPaused(
|
||||
job.getId(), modelId, "AUTO_KILLED_ON_SERVER_RESTART");
|
||||
|
||||
log.info("job = {}", job);
|
||||
markStepStopByJobType(job, "AUTO_KILLED_ON_SERVER_RESTART");
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -183,6 +194,8 @@ public class JobRecoveryOnStartupService {
|
||||
modelTrainJobCoreService.markSuccess(job.getId(), 0);
|
||||
// model 상태 변경
|
||||
markStepSuccessByJobType(job);
|
||||
// 결과 csv 파일 정보 등록
|
||||
modelTrainMetricsJobService.findTrainValidMetricCsvFiles();
|
||||
|
||||
} else {
|
||||
// 5-2) exitCode != 0 이거나 null이면 실패로 간주 → FAILED 처리
|
||||
@@ -348,33 +361,66 @@ public class JobRecoveryOnStartupService {
|
||||
*/
|
||||
private OutputResult probeOutputs(ModelTrainJobDto job) {
|
||||
try {
|
||||
|
||||
log.info(
|
||||
"[RECOVERY] probeOutputs start. jobId={}, modelId={}", job.getId(), job.getModelId());
|
||||
|
||||
// 1) 출력 디렉토리 확인
|
||||
Path outDir = resolveOutputDir(job);
|
||||
if (outDir == null || !Files.isDirectory(outDir)) {
|
||||
log.warn("[RECOVERY] output directory missing. jobId={}, path={}", job.getId(), outDir);
|
||||
return new OutputResult(false, "output-dir-missing");
|
||||
}
|
||||
|
||||
log.info("[RECOVERY] output directory found. jobId={}, path={}", job.getId(), outDir);
|
||||
|
||||
// 2) totalEpoch 확인
|
||||
Integer totalEpoch = extractTotalEpoch(job).orElse(null);
|
||||
if (totalEpoch == null || totalEpoch <= 0) {
|
||||
log.warn(
|
||||
"[RECOVERY] totalEpoch missing or invalid. jobId={}, totalEpoch={}",
|
||||
job.getId(),
|
||||
totalEpoch);
|
||||
return new OutputResult(false, "total-epoch-missing");
|
||||
}
|
||||
|
||||
log.info("[RECOVERY] totalEpoch={}. jobId={}", totalEpoch, job.getId());
|
||||
|
||||
// 3) val.csv 존재 확인
|
||||
Path valCsv = outDir.resolve("val.csv");
|
||||
if (!Files.exists(valCsv)) {
|
||||
log.warn("[RECOVERY] val.csv missing. jobId={}, path={}", job.getId(), valCsv);
|
||||
return new OutputResult(false, "val.csv-missing");
|
||||
}
|
||||
|
||||
// 4) val.csv 라인 수 확인
|
||||
long lines = countNonHeaderLines(valCsv);
|
||||
|
||||
// “같아야 완료” 정책
|
||||
log.info(
|
||||
"[RECOVERY] val.csv lines counted. jobId={}, lines={}, expected={}",
|
||||
job.getId(),
|
||||
lines,
|
||||
totalEpoch);
|
||||
|
||||
// 5) 완료 판정
|
||||
if (lines == totalEpoch) {
|
||||
log.info("[RECOVERY] outputs look COMPLETE. jobId={}", job.getId());
|
||||
return new OutputResult(true, "ok");
|
||||
}
|
||||
|
||||
log.warn(
|
||||
"[RECOVERY] val.csv line mismatch. jobId={}, lines={}, expected={}",
|
||||
job.getId(),
|
||||
lines,
|
||||
totalEpoch);
|
||||
|
||||
return new OutputResult(
|
||||
false, "val.csv-lines-mismatch lines=" + lines + " expected=" + totalEpoch);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
log.error("[RECOVERY] probeOutputs error. jobId={}", job.getId(), e);
|
||||
|
||||
return new OutputResult(false, "probe-error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class TmpDatasetService {
|
||||
|
||||
Path tmp = Path.of(trainBaseDir, "tmp", uid);
|
||||
|
||||
long hardlinksMade = 0;
|
||||
long linksMade = 0;
|
||||
|
||||
for (ModelTrainLinkDto dto : links) {
|
||||
|
||||
@@ -54,27 +54,26 @@ public class TmpDatasetService {
|
||||
Files.createDirectories(tmp.resolve(type).resolve("label-json"));
|
||||
|
||||
// comparePath → input1
|
||||
hardlinksMade += link(tmp, type, "input1", dto.getComparePath());
|
||||
linksMade += link(tmp, type, "input1", dto.getComparePath());
|
||||
|
||||
// targetPath → input2
|
||||
hardlinksMade += link(tmp, type, "input2", dto.getTargetPath());
|
||||
linksMade += link(tmp, type, "input2", dto.getTargetPath());
|
||||
|
||||
// labelPath → label
|
||||
hardlinksMade += link(tmp, type, "label", dto.getLabelPath());
|
||||
linksMade += link(tmp, type, "label", dto.getLabelPath());
|
||||
|
||||
// geoJsonPath -> label-json
|
||||
hardlinksMade += link(tmp, type, "label-json", dto.getGeoJsonPath());
|
||||
linksMade += link(tmp, type, "label-json", dto.getGeoJsonPath());
|
||||
}
|
||||
|
||||
if (hardlinksMade == 0) {
|
||||
throw new IOException("No hardlinks created.");
|
||||
if (linksMade == 0) {
|
||||
throw new IOException("No symlinks created.");
|
||||
}
|
||||
|
||||
log.info("tmp dataset created: {}, hardlinksMade={}", tmp, hardlinksMade);
|
||||
log.info("tmp dataset created: {}, linksMade={}", tmp, linksMade);
|
||||
}
|
||||
|
||||
private long link(Path tmp, String type, String part, String fullPath) throws IOException {
|
||||
|
||||
if (fullPath == null || fullPath.isBlank()) return 0;
|
||||
|
||||
Path src = Path.of(fullPath);
|
||||
@@ -87,20 +86,18 @@ public class TmpDatasetService {
|
||||
String fileName = src.getFileName().toString();
|
||||
Path dst = tmp.resolve(type).resolve(part).resolve(fileName);
|
||||
|
||||
// 충돌 시 덮어쓰기
|
||||
if (Files.exists(dst)) {
|
||||
Files.createDirectories(dst.getParent());
|
||||
|
||||
if (Files.exists(dst) || Files.isSymbolicLink(dst)) {
|
||||
Files.delete(dst);
|
||||
}
|
||||
|
||||
Files.createLink(dst, src);
|
||||
Files.createSymbolicLink(dst, src);
|
||||
log.info("symlink created: {} -> {}", dst, src);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private String safe(String s) {
|
||||
return (s == null || s.isBlank()) ? null : s.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* request 전체 폴더 link
|
||||
*
|
||||
@@ -111,7 +108,7 @@ public class TmpDatasetService {
|
||||
*/
|
||||
public String buildTmpDatasetSymlink(String uid, List<String> datasetUids) throws IOException {
|
||||
|
||||
log.info("========== buildTmpDatasetHardlink START ==========");
|
||||
log.info("========== buildTmpDatasetSymlink START ==========");
|
||||
log.info("uid={}", uid);
|
||||
log.info("datasetUids={}", datasetUids);
|
||||
log.info("requestDir(raw)={}", requestDir);
|
||||
@@ -123,7 +120,7 @@ public class TmpDatasetService {
|
||||
log.info("BASE exists? {}", Files.isDirectory(BASE));
|
||||
log.info("tmp={}", tmp);
|
||||
|
||||
long noDir = 0, scannedDirs = 0, regularFiles = 0, hardlinksMade = 0;
|
||||
long noDir = 0, scannedDirs = 0, regularFiles = 0, symlinksMade = 0;
|
||||
|
||||
// tmp 디렉토리 준비
|
||||
for (String type : List.of("train", "val", "test")) {
|
||||
@@ -134,26 +131,7 @@ public class TmpDatasetService {
|
||||
}
|
||||
}
|
||||
|
||||
// 하드링크는 "같은 파일시스템"에서만 가능하므로 BASE/tmp가 같은 FS인지 미리 확인(권장)
|
||||
try {
|
||||
var baseStore = Files.getFileStore(BASE);
|
||||
var tmpStore = Files.getFileStore(tmp.getParent()); // BASE/tmp
|
||||
if (!baseStore.name().equals(tmpStore.name()) || !baseStore.type().equals(tmpStore.type())) {
|
||||
throw new IOException(
|
||||
"Hardlink requires same filesystem. baseStore="
|
||||
+ baseStore.name()
|
||||
+ "("
|
||||
+ baseStore.type()
|
||||
+ "), tmpStore="
|
||||
+ tmpStore.name()
|
||||
+ "("
|
||||
+ tmpStore.type()
|
||||
+ ")");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// FileStore 비교가 환경마다 애매할 수 있어서, 여기서는 경고만 주고 실제 createLink에서 최종 판단하게 둘 수도 있음.
|
||||
log.warn("FileStore check skipped/failed (will rely on createLink): {}", e.toString());
|
||||
}
|
||||
// 심볼릭 링크는 파일시스템이 달라도 작동하므로 FileStore 체크 불필요
|
||||
|
||||
for (String id : datasetUids) {
|
||||
Path srcRoot = BASE.resolve(id);
|
||||
@@ -191,13 +169,12 @@ public class TmpDatasetService {
|
||||
}
|
||||
|
||||
try {
|
||||
// 하드링크 생성 (dst가 새 파일로 생기지만 inode는 f와 동일)
|
||||
Files.createLink(dst, f);
|
||||
hardlinksMade++;
|
||||
log.debug("created hardlink: {} => {}", dst, f);
|
||||
// 심볼릭 링크 생성 (파일시스템이 달라도 작동)
|
||||
Files.createSymbolicLink(dst, f);
|
||||
symlinksMade++;
|
||||
log.debug("created symlink: {} => {}", dst, f);
|
||||
} catch (IOException e) {
|
||||
// 여기서 바로 실패시키면 “tmp는 만들었는데 내용은 0개” 같은 상태를 방지할 수 있음
|
||||
log.error("FAILED create hardlink: {} => {}", dst, f, e);
|
||||
log.error("FAILED create symlink: {} => {}", dst, f, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
@@ -206,9 +183,9 @@ public class TmpDatasetService {
|
||||
}
|
||||
}
|
||||
|
||||
if (hardlinksMade == 0) {
|
||||
if (symlinksMade == 0) {
|
||||
throw new IOException(
|
||||
"No hardlinks created. regularFiles="
|
||||
"No symlinks created. regularFiles="
|
||||
+ regularFiles
|
||||
+ ", scannedDirs="
|
||||
+ scannedDirs
|
||||
@@ -218,11 +195,11 @@ public class TmpDatasetService {
|
||||
|
||||
log.info("tmp dataset created: {}", tmp);
|
||||
log.info(
|
||||
"summary: scannedDirs={}, noDir={}, regularFiles={}, hardlinksMade={}",
|
||||
"summary: scannedDirs={}, noDir={}, regularFiles={}, symlinksMade={}",
|
||||
scannedDirs,
|
||||
noDir,
|
||||
regularFiles,
|
||||
hardlinksMade);
|
||||
symlinksMade);
|
||||
|
||||
return uid;
|
||||
}
|
||||
|
||||
@@ -108,6 +108,10 @@ public class TrainJobWorker {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0 정상 종료 SUCCESS 1~125 학습 코드 에러 FAILED 137 OOMKill FAILED 143 SIGTERM (stop) STOP -1 우리 내부
|
||||
* 강제 중단 STOP
|
||||
*/
|
||||
if (result.getExitCode() == 0) {
|
||||
// 성공 처리
|
||||
modelTrainJobCoreService.markSuccess(jobId, result.getExitCode());
|
||||
@@ -124,17 +128,34 @@ public class TrainJobWorker {
|
||||
}
|
||||
|
||||
} else {
|
||||
String failMsg = result.getStatus() + "\n" + result.getLogs();
|
||||
// 실패 처리
|
||||
modelTrainJobCoreService.markFailed(
|
||||
jobId, result.getExitCode(), result.getStatus() + "\n" + result.getLogs());
|
||||
|
||||
if (isEval) {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markStep2Error(modelId, "exit=" + result.getExitCode());
|
||||
String failMsg = result.getStatus() + "\n" + result.getLogs();
|
||||
log.info("training fail exitCode={} Msg ={}", result.getExitCode(), failMsg);
|
||||
|
||||
if (result.getExitCode() == -1 || result.getExitCode() == 143) {
|
||||
// 실패 처리
|
||||
modelTrainJobCoreService.markPaused(
|
||||
jobId, result.getExitCode(), result.getStatus() + "\n" + result.getLogs());
|
||||
|
||||
if (isEval) {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markStep2Stop(modelId, "exit=" + result.getExitCode());
|
||||
} else {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markStep1Stop(modelId, "exit=" + result.getExitCode());
|
||||
}
|
||||
} else {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markError(modelId, "exit=" + result.getExitCode());
|
||||
// 실패 처리
|
||||
modelTrainJobCoreService.markFailed(
|
||||
jobId, result.getExitCode(), result.getStatus() + "\n" + result.getLogs());
|
||||
|
||||
if (isEval) {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markStep2Error(modelId, "exit=" + result.getExitCode());
|
||||
} else {
|
||||
// 오류 정보 등록
|
||||
modelTrainMngCoreService.markError(modelId, "exit=" + result.getExitCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ spring:
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://192.168.2.127:15432/kamco_training_db
|
||||
# url: jdbc:postgresql://localhost:15432/kamco_training_db
|
||||
username: kamco_training_user
|
||||
password: kamco_training_user_2025_!@#
|
||||
hikari:
|
||||
@@ -48,7 +47,7 @@ member:
|
||||
init_password: kamco1234!
|
||||
|
||||
swagger:
|
||||
local-port: 9080
|
||||
local-port: 8080
|
||||
|
||||
file:
|
||||
sync-root-dir: /app/original-images/
|
||||
@@ -70,3 +69,4 @@ train:
|
||||
containerPrefix: kamco-cd-train
|
||||
shmSize: 16g
|
||||
ipcHost: true
|
||||
|
||||
|
||||
@@ -4,19 +4,16 @@ spring:
|
||||
on-profile: prod
|
||||
|
||||
jpa:
|
||||
show-sql: true
|
||||
show-sql: false # 운영 환경에서는 성능을 위해 비활성화
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
properties:
|
||||
hibernate:
|
||||
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
|
||||
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
|
||||
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
|
||||
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
|
||||
default_batch_fetch_size: 100 # N+1 쿼리 방지
|
||||
order_updates: true # 업데이트 순서 정렬로 데드락 방지
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://kamco-cd-train-db:5432/kamco_training_db
|
||||
# url: jdbc:postgresql://localhost:15432/kamco_training_db
|
||||
username: kamco_training_user
|
||||
password: kamco_training_user_2025_!@#
|
||||
hikari:
|
||||
@@ -31,13 +28,14 @@ spring:
|
||||
default-timeout: 300 # 5분 트랜잭션 타임아웃
|
||||
|
||||
jwt:
|
||||
secret: "kamco_token_dev_dfc6446d-68fc-4eba-a2ff-c80a14a0bf3a"
|
||||
# ⚠️ 운영 환경에서는 반드시 별도의 강력한 시크릿 키를 사용하세요
|
||||
secret: "kamco_token_prod_CHANGE_THIS_TO_SECURE_SECRET_KEY"
|
||||
access-token-validity-in-ms: 86400000 # 1일
|
||||
refresh-token-validity-in-ms: 604800000 # 7일
|
||||
|
||||
token:
|
||||
refresh-cookie-name: kamco # 개발용 쿠키 이름
|
||||
refresh-cookie-secure: false # 로컬 http 테스트면 false
|
||||
refresh-cookie-name: kamco
|
||||
refresh-cookie-secure: true # HTTPS 환경에서 필수
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
@@ -70,3 +68,5 @@ train:
|
||||
shmSize: 16g
|
||||
ipcHost: true
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,10 +10,6 @@ spring:
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
hikari:
|
||||
jdbc:
|
||||
time_zone: UTC
|
||||
batch_size: 50
|
||||
# 권장 설정
|
||||
minimum-idle: 2
|
||||
maximum-pool-size: 2
|
||||
connection-timeout: 20000
|
||||
@@ -21,18 +17,11 @@ spring:
|
||||
max-lifetime: 1800000
|
||||
leak-detection-threshold: 60000
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password:
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: update # 스키마 자동 관리 활성화
|
||||
properties:
|
||||
hibernate:
|
||||
hbm2ddl:
|
||||
auto: update
|
||||
javax:
|
||||
persistence:
|
||||
validation:
|
||||
@@ -54,6 +43,9 @@ logging:
|
||||
web: INFO
|
||||
security: INFO
|
||||
root: INFO
|
||||
|
||||
|
||||
|
||||
# actuator
|
||||
management:
|
||||
health:
|
||||
@@ -77,20 +69,3 @@ management:
|
||||
exposure:
|
||||
include:
|
||||
- "health"
|
||||
|
||||
# GeoJSON 파일 모니터링 설정
|
||||
geojson:
|
||||
monitor:
|
||||
watch-directory: ~/geojson/upload
|
||||
processed-directory: ~/geojson/processed
|
||||
error-directory: ~/geojson/error
|
||||
temp-directory: /tmp/geojson_extract
|
||||
cron-expression: "0/30 * * * * *" # 매 30초마다 실행
|
||||
supported-extensions:
|
||||
- zip
|
||||
- tar
|
||||
- tar.gz
|
||||
- tgz
|
||||
max-file-size: 104857600 # 100MB
|
||||
|
||||
|
||||
|
||||
@@ -18,12 +18,6 @@ spring:
|
||||
max-lifetime: 1800000
|
||||
leak-detection-threshold: 60000
|
||||
|
||||
data:
|
||||
redis:
|
||||
host: localhost
|
||||
port: 6379
|
||||
password:
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
ddl-auto: none # 테스트 환경에서는 DDL 자동 생성/수정 비활성화
|
||||
@@ -69,20 +63,6 @@ management:
|
||||
include:
|
||||
- "health"
|
||||
|
||||
geojson:
|
||||
monitor:
|
||||
watch-directory: ~/geojson/upload
|
||||
processed-directory: ~/geojson/processed
|
||||
error-directory: ~/geojson/error
|
||||
temp-directory: /tmp/geojson_extract
|
||||
cron-expression: "0/30 * * * * *"
|
||||
supported-extensions:
|
||||
- zip
|
||||
- tar
|
||||
- tar.gz
|
||||
- tgz
|
||||
max-file-size: 104857600
|
||||
|
||||
jwt:
|
||||
secret: "test_secret_key_for_testing_purposes_only"
|
||||
access-token-validity-in-ms: 86400000
|
||||
|
||||
Reference in New Issue
Block a user