From 60de010723faa9a164585822f037e57c83355299 Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Tue, 4 Apr 2023 11:11:57 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E5=AE=B9=E5=99=A8?= =?UTF-8?q?=E7=BC=96=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置容器的健康检查 --- doc/docker/docker-compose.yml | 135 +++++++++++++++++++++++++++++----- 1 file changed, 116 insertions(+), 19 deletions(-) diff --git a/doc/docker/docker-compose.yml b/doc/docker/docker-compose.yml index a5c166a..db51692 100644 --- a/doc/docker/docker-compose.yml +++ b/doc/docker/docker-compose.yml @@ -86,7 +86,7 @@ services: - ELASTICSEARCH_HOSTS=http://novel-elasticsearch:9200 - ELASTICSEARCH_USERNAME=kibana_system - ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD} -# - ELASTICSEARCH_SSL_VERIFICATIONMODE=none + # - ELASTICSEARCH_SSL_VERIFICATIONMODE=none ports: - "5601:5601" depends_on: @@ -141,6 +141,15 @@ services: - novel-mysql networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:8848 | grep -q 'HTTP/1.1 404'", + ] + interval: 30s + timeout: 2s + retries: 120 novel-gateway: build: ./novel-gateway @@ -153,10 +162,20 @@ services: ports: - "8888:8888" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet - + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:8888 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 + novel-home-service: build: ./novel-home-service image: novel-home-service:${NOVEL_CLOUD_VERSION} @@ -168,9 +187,19 @@ services: ports: - "9001:9001" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9001 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-news-service: build: ./novel-news-service @@ -183,10 +212,20 @@ services: ports: - "9030:9030" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet - + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9030 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 + novel-book-service: build: ./novel-book-service image: novel-book-service:${NOVEL_CLOUD_VERSION} @@ -198,9 +237,19 @@ services: ports: - "9020:9020" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9020 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-user-service: build: ./novel-user-service @@ -213,9 +262,19 @@ services: ports: - "9060:9060" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9060 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-search-service: build: ./novel-search-service @@ -228,9 +287,19 @@ services: ports: - "9050:9050" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9050 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-resource-service: build: ./novel-resource-service @@ -243,9 +312,19 @@ services: ports: - "9040:9040" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9040 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-author-service: build: ./novel-author-service @@ -258,9 +337,19 @@ services: ports: - "9010:9010" depends_on: - - novel-nacos-server + novel-nacos-server: + condition: service_healthy networks: - novelnet + healthcheck: + test: + [ + "CMD-SHELL", + "curl -s -I http://localhost:9010 | grep -q 'HTTP/1.1 404 Not Found'", + ] + interval: 10s + timeout: 2s + retries: 120 novel-monitor: build: ./novel-monitor @@ -273,14 +362,22 @@ services: ports: - "8898:8898" depends_on: - - novel-gateway - - novel-home-service - - novel-author-service - - novel-book-service - - novel-search-service - - novel-user-service - - novel-resource-service - - novel-news-service + novel-gateway: + condition: service_healthy + novel-home-service: + condition: service_healthy + novel-author-service: + condition: service_healthy + novel-book-service: + condition: service_healthy + novel-search-service: + condition: service_healthy + novel-user-service: + condition: service_healthy + novel-resource-service: + condition: service_healthy + novel-news-service: + condition: service_healthy networks: - novelnet