Spring Cloud Config未准备好,需要docker-compose延迟

时间:2019-05-30 11:43:43

标签: docker-compose spring-cloud-config

作为单个docker-compose文件的一部分,我们正在启动spring-config-cloud-server和client。客户端在服务器容器上有一个depends_on。但是,服务器容器启动与客户端启动并要求其配置之间的延迟太快,服务器还没有机会提取配置-我们确实有cloneOnStart: true

客户端失败后(数据源连接失败)。我可以手动泊坞窗停止,然后泊坞窗启动客户端,一切正常。

我们尝试向服务器添加运行状况检查,但这不能解决问题。

spring:
  security:
    user:
      name: config-user
      password: myPassword
      role: USER
  application:
    name: config-server
  cloud:
    config:
      fail-fast: true
      request-read-timeout: 10
      server:
        git:
          uri: xxxxxx/config-store.git
          searchPaths: '{application}/{profile}'
          cloneOnStart: true
          ignoreLocalSshSettings: true
          strictHostKeyChecking: false
          basedir: target/config
          deleteUntrackedBranches: true
          force-pull: true
          refreshRate: 60
          skipSslValidation: false
          privateKey: |

docker-compose:

version: '3.7'
services:
  config-server: 
    image: config-server:1.0.0 
    container_name: config-server
    restart: always
    ports: 
      - 8888:8888
    environment:
      - "TZ=UTC"
    networks: 
      - services-network
    volumes:
      - ./config/config-server-prod.yml:/application.yml:ro
    healthcheck:
      test: ["CMD-SHELL", "curl -f http://localhost:8888 || exit 1"]
      interval: 10s
      timeout: 10s
      retries: 10

  config-client: 
    image: config-client:1.2.1 
    container_name: config-client
    ports:
      - 8200:8200 
    environment:
      - "TZ=UTC"
    networks: 
      - services-network
    links: 
      - "ap-config-svc"
    command: "/bin/sleep 30"
    volumes: 
      - ./config/config-client-application.yaml:/application.yaml:ro 
      - ./config/config-client-bootstrap.yaml:/bootstrap.yaml:ro 
    depends_on: 
      - config-server

networks:
  services-network:

bootstrap.yaml:

spring:
  application:
    name: ap-eox-svc
  cloud:
    config:
      uri: http://config-server:8888

0 个答案:

没有答案