fix: iot-gateway去除健康检查、nacos配置
Some checks failed
Java CI with Maven / build (11) (push) Has been cancelled
Java CI with Maven / build (17) (push) Has been cancelled
Java CI with Maven / build (8) (push) Has been cancelled

This commit is contained in:
lzh
2026-01-14 17:48:00 +08:00
parent 244c8aee96
commit bcbbde1879
5 changed files with 38 additions and 53 deletions

35
Jenkinsfile vendored
View File

@@ -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")

View File

@@ -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

View File

@@ -23,12 +23,7 @@
<version>${revision}</version>
</dependency>
<!-- 监控相关 -->
<dependency>
<groupId>com.viewsh</groupId>
<artifactId>viewsh-spring-boot-starter-monitor</artifactId>
</dependency>
<!-- Web 相关(轻量化,仅提供基础 Web 抽象) -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>

View File

@@ -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:

View File

@@ -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: