Skip to content

auth server 헬스체크 안되는 문제 #56

@ksah3756

Description

@ksah3756

auth-service에서 액세스 토큰을 발급받아 사용하는 리소스 서버들(account-service, notification-service, statistics-service)은
서버 시작할 때 한 번 auth-service의 http://auth-service:5000/oauth2/jwks 엔드포인트로 요청을 보내서 JWT 검증을 할때 사용할 공개 키를 받아와야 하기 때문에(JWT 액세스 토큰을 검증할 때 사용)
auth-service가 먼저 실행이 되어야 함, 그렇지 않으면 아래와 같은 에러 발생하고 서버 실행이 안됨
스크린샷 2025-01-01 오후 10 15 16

따라서 docker 설정에 auth-service 헬스체크를 추가하고 다른 서비스들은 depends_on 설정으로 auth-service가 healthy 상태가 되면 실행되도록 하려 했는데 auth-service 헬스체크가 안됨..실제로는 해당 엔드포인트에 접속이 되는데
두 가지 방법으로 해봤는데 저는 일단 다 안됐습니다..

  1. docker-compose-test.yml 수정
  auth-service:
    build:
      context: ./auth-service
    container_name: auth-service
    ports:
      - 5000:5000
#    healthcheck: # 왜 안될까..
#      test: [ "CMD", "curl", "-f", "http://localhost:5000/.well-known/openid-configuration" ]
#      interval: 10s
#      timeout: 5s
#      retries: 3
#      start_period: 30s  # 초기화 시간 10초 대기
  1. auth-service 내 dockerfile 수정
FROM openjdk:17-jdk-slim

ADD ./build/libs/auth-service-1.0-SNAPSHOT.jar /app/
CMD ["java", "-Xmx200m", "-jar", "/app/auth-service-1.0-SNAPSHOT.jar"]

#HEALTHCHECK --interval=30s --timeout=30s CMD curl -f http://localhost:5000/.well-known/openid-configuration || exit 1

EXPOSE 5000

이 문제를 해결을 못해서 일단은 위 에러가 나면 서버를 재시작하면 그때는 제대로 공개키를 가져와서 일단 테스트할 때 계속 이런 방식으로 했는데...아시는 분 있으시면 해결 좀 부탁드립니다

마찬가지로 registry(유레카 서버)도 healthy 상태 확인되면 나머지 서비스들이 실행되어야 할 거 같은데 얘도 헬스 체크가 안됨

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions