fix: PR#190 review 修复 — 配置查找顺序/页面日志/ZIP结构/注释

- 配置文件查找顺序与 Deploy 保持一致(先当前目录,再 resources/)
- 页面地址日志改用 onComplete,无论演练场加载成功失败均输出
- Windows ZIP 移除 /* 通配符,与 Linux 保持一致的顶层目录结构
- 修正注释:同步读文件会阻塞 event loop,不再声称'避免阻塞'
- YAML 正则和 jdeps 回退列表补充适用范围说明
This commit is contained in:
yukaidi
2026-05-31 16:18:12 +08:00
parent d55d8edd2f
commit 0feb8e798a
2 changed files with 9 additions and 5 deletions

View File

@@ -163,6 +163,7 @@ jobs:
--class-path "$CP" "$MAIN_JAR" 2>/dev/null | head -n 1 | tr -d '\r\n' || true)
if [ -z "$RAW_MODULES" ] || [[ "$RAW_MODULES" == *"Missing"* ]] || [[ "$RAW_MODULES" == *"Error"* ]]; then
# ⚠️ 回退列表:若项目新增了需要 java.* / jdk.* 模块的依赖,需同步更新此处
RAW_MODULES="java.base,java.logging,java.sql,java.naming,java.management,java.xml,jdk.unsupported,java.net.http,java.instrument,java.security.jgss,java.security.sasl,java.desktop,jdk.crypto.ec"
echo "jdeps 分析失败,使用回退模块列表"
else
@@ -252,7 +253,7 @@ jobs:
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive -Path native-package/netdisk-fast-download/* -DestinationPath "${{ matrix.artifact-name }}.zip"
Compress-Archive -Path native-package/netdisk-fast-download -DestinationPath "${{ matrix.artifact-name }}.zip"
# ============================================================
# 上传产物

View File

@@ -84,17 +84,19 @@ public class AppMain {
if (addr == null || addr.isBlank()) {
addr = "http://127.0.0.1:" + jsonObject.getJsonObject(ConfigConstant.SERVER).getInteger("port", 6400);
}
// 读取代理配置获取前端页面端口(同步读文件,避免阻塞 event loop
// 读取代理配置获取前端页面端口(同步读取小文件,仅启动时执行一次
String proxyConfName = jsonObject.getString("proxyConf", "server-proxy");
String pageAddr = addr;
try {
String configFile = proxyConfName + ".yml";
Path configPath = Path.of("resources", configFile);
// 与 Deploy 保持一致:优先当前目录,其次 resources/
Path configPath = Path.of(configFile);
if (!Files.exists(configPath)) {
configPath = Path.of(configFile);
configPath = Path.of("resources", configFile);
}
if (Files.exists(configPath)) {
String yamlContent = Files.readString(configPath);
// 匹配项目约定的 YAML 格式: "- listen: 8080"
java.util.regex.Matcher m = java.util.regex.Pattern
.compile("^\\s*-\\s+listen:\\s*(\\d+)", java.util.regex.Pattern.MULTILINE)
.matcher(yamlContent);
@@ -186,9 +188,10 @@ public class AppMain {
} else {
log.info("未找到已发布的演练场解析器");
}
log.info("服务已启动,可通过 {} 访问页面", accessAddr);
}).onFailure(e -> {
log.error("加载演练场解析器列表失败", e);
}).onComplete(ar -> {
log.info("服务已启动,可通过 {} 访问页面", accessAddr);
});
}
}