728x90
반응형
SMALL
폐쇠망에서의 Spring Cloud Config Server 설정 파일 변경시 재시작 Life Cycle

외부와의 통신이 열려있는 오픈망일 경우 Spring Cloud Config Server의 yml 파일을 변경하고 변경된것을 대표적으로 git 과 같은 저장소에 push를 하면 Config Server가 event를 catch 해서 Config Server와 바인딩된 모듈들(Config Client)의 설정정보를 자동적으로 refresh 해주기 때문에 동적으로 적용하기 편리하다.
그러나 나는 폐쇠망이기 때문에 위의 내용을 수동적해주는 무언가가 필요했다.
git local server 를 구성 하거나 db, redis 를 사용하여 발생된 event를 catch하면 가능하지만 오버엔지니어링 이라 판단했고 좀더 간단한 방법을 고민했다.
결국
Spring Actuator Endpoint의 Shutdown과 Docker의 --restart=always 옵션으로 고민을 해결했다.
의존성 등록
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.cloud:spring-cloud-config-client'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter:4.0.4'
}
클라이언트 모듈의 yml
server:
shutdown: graceful
management:
endpoints:
web:
base-path: /test
exposure:
include: '*'
jms:
exposure:
include: '*'
endpoint:
shutdown:
enabled: true
endpoint.shutdown.enable = true 로 해주면 POST 로 shutdown 엔드포인트에 접근이 가능하다.
하던일을 끝마치고 종료되어야 되기 때문에 server.shutdown = graceful은 신경써주자.
shutdown 요청시 메시지 확인

모듈은 Docker Container로 띄었는데 --restart=always 옵션을 추가해주면
Docker Container 내부에서 돌고있는 애플리케이션만 종료시키더라도 그걸 감지해서 자동으로 restart 해준다.
728x90
반응형
LIST
'나의 주니어 개발 일기 > Docker(도커)' 카테고리의 다른 글
| 도커 jdk 이미지로만 jar 실행 (0) | 2023.10.19 |
|---|---|
| 폐쇄망에서의 리눅스 reboot시 Docker 자동 실행 (0) | 2023.08.25 |
| Docker Container 모니터링 하기 (1) | 2023.08.23 |
| Docker Container 를 이미지화 하여 Docker Hub에 Push,Pull하기 (0) | 2023.08.14 |
| [Docker] 1.CentOs 에 Docker 설치하기 (0) | 2022.02.18 |