From 61ea1f587c8003c2cd89d0f799149c6f328d26b4 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期一, 14 七月 2025 16:03:51 +0800
Subject: [PATCH] 添加健康检测功能

---
 docker/docker-compose.yml |   34 ++++++++++++++++++++++++++--------
 1 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 39cc616..7a9e2e1 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -16,7 +16,7 @@
       POSTGRES_DB: jhs
     healthcheck:
       test: ["CMD-SHELL", "pg_isready -U postgres"]
-      interval: 5s
+      interval: 10s
       timeout: 2s
       retries: 3
     privileged: true
@@ -41,6 +41,12 @@
       - ./nacos/logs/:/home/nacos/logs
       - ./nacos/plugins:/home/nacos/plugins
       #- ./nacos/conf/application.properties:/home/nacos/conf/application.properties
+    healthcheck:
+      test: ["CMD-SHELL", "curl -f http://localhost:8080 || exit 1"]
+      interval: 10s
+      timeout: 2s
+      retries: 3
+      start_period: 10s
     ports:
       - 8080:8080
       - 8848:8848
@@ -60,6 +66,11 @@
     volumes:
       - ./redis/redis.conf:/data/redis.conf
       - ./redis/data:/data
+    healthcheck:
+      test: ["CMD", "redis-cli", "ping"]
+      interval: 10s
+      timeout: 2s
+      retries: 3
     #command: redis-server --requirepass Redis_s!E_6.2.6
     command: redis-server /data/redis.conf
     networks:
@@ -72,10 +83,13 @@
       - ./gateway:/app
     environment:
       TZ: Asia/Shanghai
-    entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-gateway.jar --spring.config.location=file:/app/"
+    #entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-gateway.jar --spring.config.location=file:/app/"
+    entrypoint: java -jar /app/se-gateway.jar --spring.config.location=file:/app/
     depends_on:
-      - redis
-      - nacos
+      redis:
+        condition: service_healthy
+      nacos:
+        condition: service_healthy
     networks:
       - network-jhs
   # system
@@ -86,11 +100,15 @@
       - ./system:/app
     environment:
       TZ: Asia/Shanghai
-    entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-system.jar --spring.config.location=file:/app/"
+    #entrypoint: /bin/sh -c "sleep 30 && java -jar /app/se-system.jar --spring.config.location=file:/app/"
+    entrypoint: java -jar /app/se-system.jar --spring.config.location=file:/app/
     depends_on:
-      - postgis
-      - nacos
-      - redis
+      postgis:
+        condition: service_healthy
+      redis:
+        condition: service_healthy
+      nacos:
+        condition: service_healthy
     networks:
       - network-jhs
   # nginx

--
Gitblit v1.9.3