mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
fix: PR#190 review 修复 — 配置查找顺序/页面日志/ZIP结构/注释
- 配置文件查找顺序与 Deploy 保持一致(先当前目录,再 resources/) - 页面地址日志改用 onComplete,无论演练场加载成功失败均输出 - Windows ZIP 移除 /* 通配符,与 Linux 保持一致的顶层目录结构 - 修正注释:同步读文件会阻塞 event loop,不再声称'避免阻塞' - YAML 正则和 jdeps 回退列表补充适用范围说明
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user