From 44a23ac5429bbc0beed58c953f1f138c0729c0f2 Mon Sep 17 00:00:00 2001 From: dingzhaojun Date: Mon, 8 Jan 2024 06:31:25 +0800 Subject: [PATCH] consul update --- compose-traefik.yml | 7 ++++++- src/main/resources/application.yml | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/compose-traefik.yml b/compose-traefik.yml index 262ac31..f32e2f4 100644 --- a/compose-traefik.yml +++ b/compose-traefik.yml @@ -35,7 +35,7 @@ services: - "--api.insecure=true" - "--api.debug=false" - "--ping=true" - - "--log.level=INFO" + - "--log.level=DEBUG" - "--log.format=common" - "--accesslog=false" - "--entrypoints.web.address=:8081" @@ -53,6 +53,11 @@ services: - "--providers.file.watch=true" - "--providers.file.directory=/etc/traefik/dynamic" - "--providers.file.debugloggeneratedtemplate=true" + - "--providers.consulCatalog=true" + - "--providers.consulCatalog.endpoint.address=consul:8500" + - "--providers.consulCatalog.exposedByDefault=false" + - "--providers.consulCatalog.stale=false" + - "--providers.consulCatalog.prefix=traefik" healthcheck: test: ["CMD-SHELL", "wget -q --spider --proxy off localhost:8080/ping || exit 1"] interval: 5s diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 2220a48..b690265 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -33,8 +33,8 @@ spring: compatibility-verifier: enabled: false consul: - host: localhost - port: 8500 + host: ${CONSUL_HOST:consul} + port: ${CONSUL_PORT:8500} discovery: register-health-check: true healthCheckPath: ${server.servlet.context-path}/actuator/health @@ -43,7 +43,12 @@ spring: metrics: ${server.servlet.context-path}/actuator/prometheus springboot: true isv: risesoft - tags: test,y9 + tags: + - traefik.enable=true + - traefik.http.routers.demo01.rule=PathPrefix(`/users`,`/actuator`) + prefer-ip-address: true + instance-id: ${spring.application.name}:${spring.application.instance-id:${random.value}} + service-name: ${spring.application.name} datasource: driverClassName: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/y9_public?serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&useUnicode=true&characterEncoding=utf-8&rewriteBatchedStatements=true&useCompression=true&useSSL=false&allowPublicKeyRetrieval=true