leo
leo

Reputation: 133

spring-cloud-config client failed to start when spring-cloud-config server not ready

here I used rancher and docker-compose to initialize spring-cloud-config client and server, but when spring-cloud-config server is not ready, the client start failed ,and need to restart when server is ready. I want to ask is there any mechanism for spring-cloud-config client reload or restart when server is ready?

Upvotes: 2

Views: 2383

Answers (1)

leo
leo

Reputation: 133

Finally, after studying http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_client_side_usage, the spring cloud config retry part, i found these answers:

Config Client Retry If you expect that the config server may occasionally be unavailable when your app starts, you can ask it to keep trying after a failure. First you need to set spring.cloud.config.failFast=true, and then you need to add spring-retry and spring-boot-starter-aop to your classpath. The default behaviour is to retry 6 times with an initial backoff interval of 1000ms and an exponential multiplier of 1.1 for subsequent backoffs. You can configure these properties (and others) using spring.cloud.config.retry.* configuration properties. TIP To take full control of the retry add a @Bean of type RetryOperationsInterceptor with id "configServerRetryInterceptor". Spring Retry has a RetryInterceptorBuilder that makes it easy to create one.

thus:

spring:
   cloud:
     config:
       fail-fast: true
     retry:
       max-attempts: 10000
       max-interval: 1000

Upvotes: 5

Related Questions