diff --git a/Jenkinsfile b/Jenkinsfile index ff61760..80af5e1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -878,6 +878,25 @@ def deployService(String service) { // 等待服务健康 def waitForServiceHealthy(String containerName, String serviceName, String sshOpts) { + // iot-gateway 是轻量化网关,不需要健康检查,只检查容器是否运行 + if (serviceName == 'viewsh-module-iot-gateway') { + echo "⏳ Waiting for ${serviceName} to start (lightweight gateway, no health check)..." + sh """ + ssh ${sshOpts} root@${env.DEPLOY_HOST} ' + set -e + sleep 5 + if docker ps | grep -q ${containerName}; then + echo "✅ ${serviceName} is running" + else + echo "❌ ${serviceName} is not running" + docker logs --tail 50 ${containerName} 2>/dev/null || true + exit 1 + fi + ' + """ + return + } + def maxAttempts = env.HEALTH_CHECK_TIMEOUT.toInteger() / env.HEALTH_CHECK_INTERVAL.toInteger() echo "⏳ Waiting for ${serviceName} to be healthy (max ${env.HEALTH_CHECK_TIMEOUT}s)..." @@ -934,6 +953,22 @@ def checkServiceHealthWithRetry(String service) { // 检查服务健康状态 def checkServiceHealth(String containerName, String serviceName, String sshOpts) { + // iot-gateway 是轻量化网关,不需要健康检查,只检查容器是否运行 + if (serviceName == 'viewsh-module-iot-gateway') { + sh """ + ssh ${sshOpts} root@${env.DEPLOY_HOST} ' + if docker ps | grep -q ${containerName}; then + echo "✅ ${serviceName} is running (lightweight gateway)" + else + echo "❌ ${serviceName} is not running" + docker logs --tail 50 ${containerName} 2>/dev/null || true + exit 1 + fi + ' + """ + return + } + sh """ ssh ${sshOpts} root@${env.DEPLOY_HOST} ' STATUS=\$(docker inspect --format="{{.State.Health.Status}}" ${containerName} 2>/dev/null || echo "not_found") diff --git a/docker-compose.core.yml b/docker-compose.core.yml index 7a0652d..1965314 100644 --- a/docker-compose.core.yml +++ b/docker-compose.core.yml @@ -188,18 +188,10 @@ services: image: ${REGISTRY_HOST:-localhost:5000}/viewsh-module-iot-gateway:${IMAGE_TAG:-latest} container_name: aiot-iot-gateway restart: on-failure:5 - ports: - - "48095:48095" environment: TZ: Asia/Shanghai SPRING_PROFILES_ACTIVE: prod JAVA_OPTS: "-Xms1024m -Xmx2048m -XX:+UseContainerSupport -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/app/logs" - - NACOS_USERNAME: nacos - NACOS_PASSWORD: 9oDxX~}e7DeP - NACOS_ADDR: 172.17.16.14:8848 - NACOS_DISCOVERY_NAMESPACE: "8efd6d96-de7f-4664-b28e-c2788ffa1395" - NACOS_CONFIG_NAMESPACE: "8efd6d96-de7f-4664-b28e-c2788ffa1395" SPRING_DATA_REDIS_HOST: 172.17.16.14 SPRING_DATA_REDIS_PASSWORD: "9kHXcZ1ojFsD" @@ -213,13 +205,6 @@ services: limits: memory: 2560m cpus: '1.5' - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:48095/actuator/health"] - interval: 10s - timeout: 5s - retries: 12 - start_period: 120s depends_on: - viewsh-module-iot-server: - condition: service_healthy + - viewsh-module-iot-server diff --git a/viewsh-module-iot/viewsh-module-iot-gateway/pom.xml b/viewsh-module-iot/viewsh-module-iot-gateway/pom.xml index a2aacbe..953216d 100644 --- a/viewsh-module-iot/viewsh-module-iot-gateway/pom.xml +++ b/viewsh-module-iot/viewsh-module-iot-gateway/pom.xml @@ -23,12 +23,7 @@ ${revision} - - - com.viewsh - viewsh-spring-boot-starter-monitor - - + org.springframework spring-web diff --git a/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application-prod.yaml b/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application-prod.yaml index 2736964..3e3e87d 100644 --- a/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application-prod.yaml +++ b/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application-prod.yaml @@ -1,22 +1,3 @@ ---- #################### 注册中心 + 配置中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: ${NACOS_ADDR:127.0.0.1:8848} - username: ${NACOS_USERNAME:nacos} - password: ${NACOS_PASSWORD:nacos} - discovery: - namespace: ${NACOS_DISCOVERY_NAMESPACE:prod} - group: DEFAULT_GROUP - metadata: - version: 1.0.0 - config: - namespace: ${NACOS_CONFIG_NAMESPACE:prod} - group: DEFAULT_GROUP - file-extension: yaml - refresh-enabled: true - --- #################### 应用配置 #################### spring: @@ -43,17 +24,6 @@ rocketmq: producer: group: ${spring.application.name}_PRODUCER ---- #################### 监控相关配置 #################### - -management: - endpoints: - web: - exposure: - include: "*" - endpoint: - health: - show-details: always - --- #################### IoT 网关相关配置 #################### viewsh: diff --git a/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application.yaml b/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application.yaml index 674027b..1f8fe0b 100644 --- a/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application.yaml +++ b/viewsh-module-iot/viewsh-module-iot-gateway/src/main/resources/application.yaml @@ -7,7 +7,7 @@ spring: config: import: - optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置 - - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 +# - optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置 # Redis 配置 data: