Config Server & Actuator

duckbill413·2024년 8월 5일
0

Spring Cloud

목록 보기
8/10
post-thumbnail

Config Server 를 활용하여 공통으로 환경 변수를 관리할 수 있게 되었지만 만약, 환경 변수가 변경된 경우 여전히 서버를 재기작 시켜야 한다.

Spring Actuator 의 refresh 를 사용하면 환경 변수를 변경했을때 서버의 재시작 없이 적용할 수 있다.


Config Server with Actuator

  1. Actuator 를 모든 애플리케이션에 추가

    // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
  2. application.yml 추가

    management:
      endpoints:
        web:
          exposure:
            include: health, beans, refresh
    • exposure.include는 Actuator 가 외부에 노출할 address 를 지정
    • refresh가 환경 변수 변경을 위한 주소
  3. http://localhost:{port}/actuator/refreshPOST 요청

    요청을 하게 되면 actuator 가 환경 변수를 다시 로딩하게 된다.

profile
같이 공부합시다~

0개의 댓글