This commit is contained in:
waner 2026-05-21 11:33:10 +08:00
parent a7337a26e1
commit 8efe13db42
2 changed files with 5 additions and 0 deletions

View File

@ -22,6 +22,8 @@ import org.springframework.stereotype.Component;
@Component
public class UpgradeTaskRunner {
private static final int DETACHED_RESTART_DELAY_SECONDS = 5;
private final UpgradeTaskRepository upgradeTaskRepository;
private final FileRecordRepository fileRecordRepository;
private final DeviceSoftwareVersionRepository deviceSoftwareVersionRepository;
@ -250,6 +252,7 @@ public class UpgradeTaskRunner {
+ "APP_HOME=\"${APP_HOME:-/home/tms}\"; "
+ "RUN_DIR=\"${RUN_DIR:-${APP_HOME}/run}\"; "
+ "PENDING_META=\"${RUN_DIR}/tms-upgrade.pending-jar\"; "
+ "sleep " + DETACHED_RESTART_DELAY_SECONDS + "; "
+ "\"${APP_HOME}/scripts/tms.sh\" stop; "
+ "if [ -s \"${PENDING_META}\" ]; then "
+ "PENDING_JAR=\"$(cat \"${PENDING_META}\")\"; "

View File

@ -188,7 +188,9 @@ class UpgradeTaskRunnerTest {
Assertions.assertTrue(command.contains("PENDING_META"));
Assertions.assertTrue(command.contains("tms-upgrade.pending-jar"));
Assertions.assertTrue(command.contains("sleep 5"));
Assertions.assertTrue(command.contains("cp \"${PENDING_JAR}\" \"${APP_HOME}/tms-framework.jar\""));
Assertions.assertTrue(command.indexOf("sleep 5") < command.indexOf("\"${APP_HOME}/scripts/tms.sh\" stop"));
Assertions.assertTrue(command.indexOf("\"${APP_HOME}/scripts/tms.sh\" stop") < command.indexOf("cp \"${PENDING_JAR}\""));
Assertions.assertTrue(command.indexOf("cp \"${PENDING_JAR}\"") < command.indexOf("\"${APP_HOME}/scripts/tms.sh\" start"));
}