application.yml

management:
  endpoint:
    shutdown:
      enabled: true
  endpoints:
    web:
      exposure:
        include:
          - shutdown
          - info
          - health
spring:
  application:
    name: eureka-provider
server:
  port: 9090
eureka:
  client:
    service-url:
      defaultZone: http://eureka1:8761/eureka,http://eureka2:8761/eureka

通过请求 http://localhost:9090/actuator/shutdown 优雅停服

以上方式会停止运行该服务。

如果你是spring boot项目可以通过以下方式停服:

    @GetMapping("/offline")
    public void offline(){
        DiscoveryManager.getInstance().shutdownComponent();
    }

这种方式只会将服务从eureka中去除但不会停止该服务。

 

相关文章:

  • 2021-11-28
  • 2021-09-17
  • 2021-08-27
  • 2022-01-18
  • 2022-01-21
  • 2021-08-26
  • 2021-04-26
猜你喜欢
  • 2022-02-06
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2021-07-14
  • 2021-12-04
相关资源
相似解决方案