From 7a7bf42165282a0b653714dcdbc22a06d7c9d603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8D=E7=BC=96=E8=AF=91=E5=B7=A5=E4=BD=9C=E5=8C=BA?= Date: Fri, 1 May 2026 23:18:31 +0800 Subject: [PATCH] fix: use wildcard JAR matching for any version, fix health endpoints to /health (Boot 1.x) Former-commit-id: 20071a784e3c5c1f8b392fd5ec8d44b500810359 --- scripts/test-env/build-elevator-v2.sh | 15 +++++++-------- scripts/test-env/health-check.sh | 8 ++++---- scripts/test-env/start-all.sh | 16 ++++++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/scripts/test-env/build-elevator-v2.sh b/scripts/test-env/build-elevator-v2.sh index 0549f96c..599a2c08 100755 --- a/scripts/test-env/build-elevator-v2.sh +++ b/scripts/test-env/build-elevator-v2.sh @@ -21,13 +21,12 @@ else exit 1 fi -# Sync JAR to deploy/ -if [[ -f "cw-elevator-application-starter/target/cw-elevator-application-2.0.7.jar" ]]; then - cp cw-elevator-application-starter/target/cw-elevator-application-2.0.7.jar \ - deploy/v2-maven/cw-elevator-application-2.0.7.jar - log_ok "JAR synced to deploy/v2-maven/" +# Sync JAR to deploy/ — use wildcard to match any version +LATEST_JAR=$(ls -t cw-elevator-application-starter/target/cw-elevator-application-*.jar 2>/dev/null | grep -v sources | head -1) +if [[ -n "$LATEST_JAR" ]]; then + cp "$LATEST_JAR" deploy/v2-maven/ + log_ok "JAR synced: $(basename "$LATEST_JAR") → deploy/v2-maven/" else - # Fallback: use sync-jars.sh - cd deploy && bash sync-jars.sh - log_ok "JAR synced via sync-jars.sh" + log_error "No JAR found in target/" + exit 1 fi diff --git a/scripts/test-env/health-check.sh b/scripts/test-env/health-check.sh index 7cf299b4..8a474021 100755 --- a/scripts/test-env/health-check.sh +++ b/scripts/test-env/health-check.sh @@ -35,10 +35,10 @@ check_tcp "Kafka" "$KAFKA_HOST" "$KAFKA_PORT" check_http "Nginx" "http://$CONSUL_HOST:$PORT_NGINX" log_info "--- Application Services ---" -check_http "elevator-v2" "http://127.0.0.1:$PORT_ELEVATOR_V2/actuator/health" -check_http "elevator-v1" "http://127.0.0.1:$PORT_ELEVATOR_V1/actuator/health" -check_http "crk-std" "http://127.0.0.1:$PORT_CRK_MGMT/actuator/health" -check_http "alarm-app" "http://127.0.0.1:$PORT_ALARM_MGMT/actuator/health" +check_http "elevator-v2" "http://127.0.0.1:$PORT_ELEVATOR_V2/health" +check_http "elevator-v1" "http://127.0.0.1:$PORT_ELEVATOR_V1/health" +check_http "crk-std" "http://127.0.0.1:$PORT_CRK_MGMT/health" +check_http "alarm-app" "http://127.0.0.1:$PORT_ALARM_MGMT/health" log_info "--- Databases ---" check_tcp "MySQL" "$MYSQL_HOST" "$MYSQL_PORT" diff --git a/scripts/test-env/start-all.sh b/scripts/test-env/start-all.sh index fc34c9ea..7d7f7344 100755 --- a/scripts/test-env/start-all.sh +++ b/scripts/test-env/start-all.sh @@ -29,7 +29,7 @@ start_service() { # 等待服务就绪 (最多 60s) for i in $(seq 1 30); do sleep 2 - if curl -sf "http://127.0.0.1:$port/actuator/health" &>/dev/null; then + if curl -sf "http://127.0.0.1:$port/health" &>/dev/null; then log_ok " $name (pid=$pid, port=$port) STARTED" return 0 fi @@ -68,16 +68,20 @@ if [[ -f "$ALARM_JAR" ]]; then start_service "alarm-app" "$ALARM_JAR" "$PORT_ALARM" "$JAVA_OPTS_HEAVY" --spring.config.location="$STAR_CENTER/ninca_qk_alarm_app_01-ninca_qk_alarm_app/" fi -# A12: elevator V2 (最后启动) -ELEVATOR_V2_JAR="$REPO_ROOT/maven-cw-elevator-application/deploy/v2-maven/cw-elevator-application-2.0.7.jar" -if [[ -f "$ELEVATOR_V2_JAR" ]]; then +# A12: elevator V2 (最后启动) — use wildcard to match any version +ELEVATOR_V2_JAR=$(ls -t "$REPO_ROOT/maven-cw-elevator-application/deploy/v2-maven/cw-elevator-application-"*.jar 2>/dev/null | head -1) +if [[ -n "$ELEVATOR_V2_JAR" ]]; then start_service "elevator-v2" "$ELEVATOR_V2_JAR" "$PORT_ELEVATOR_V2" "$JAVA_OPTS_HEAVY" --spring.config.location="$REPO_ROOT/maven-cw-elevator-application/deploy/v2-maven/" +else + log_warn "No elevator V2 JAR found in deploy/v2-maven/" fi # A13: elevator V1 (对拍对照) -ELEVATOR_V1_JAR="$REPO_ROOT/maven-cw-elevator-application/deploy/v1-legacy/cw-elevator-application-V1.0.0.20211103.jar" -if [[ -f "$ELEVATOR_V1_JAR" ]]; then +ELEVATOR_V1_JAR=$(ls -t "$REPO_ROOT/maven-cw-elevator-application/deploy/v1-legacy/cw-elevator-application-"*.jar 2>/dev/null | head -1) +if [[ -n "$ELEVATOR_V1_JAR" ]]; then start_service "elevator-v1" "$ELEVATOR_V1_JAR" "$PORT_ELEVATOR_V1" "$JAVA_OPTS_HEAVY" --spring.config.location="$REPO_ROOT/maven-cw-elevator-application/deploy/v1-legacy/" +else + log_warn "No elevator V1 JAR found in deploy/v1-legacy/" fi log_info "All services started"