mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 07:57:28 +00:00
AppMain: 启动日志增加前端页面访问地址提示
This commit is contained in:
@@ -21,6 +21,8 @@ import io.vertx.core.shareddata.LocalMap;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static cn.qaiu.vx.core.util.ConfigConstant.LOCAL;
|
import static cn.qaiu.vx.core.util.ConfigConstant.LOCAL;
|
||||||
@@ -78,12 +80,33 @@ public class AppMain {
|
|||||||
System.out.println("数据库连接成功");
|
System.out.println("数据库连接成功");
|
||||||
|
|
||||||
// 加载演练场解析器
|
// 加载演练场解析器
|
||||||
loadPlaygroundParsers();
|
|
||||||
|
|
||||||
String addr = jsonObject.getJsonObject(ConfigConstant.SERVER).getString("domainName");
|
String addr = jsonObject.getJsonObject(ConfigConstant.SERVER).getString("domainName");
|
||||||
if (addr == null || addr.isBlank()) {
|
if (addr == null || addr.isBlank()) {
|
||||||
addr = "http://127.0.0.1:" + jsonObject.getJsonObject(ConfigConstant.SERVER).getInteger("port", 6400);
|
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);
|
||||||
|
if (!Files.exists(configPath)) {
|
||||||
|
configPath = Path.of(configFile);
|
||||||
|
}
|
||||||
|
if (Files.exists(configPath)) {
|
||||||
|
String yamlContent = Files.readString(configPath);
|
||||||
|
java.util.regex.Matcher m = java.util.regex.Pattern
|
||||||
|
.compile("^\\s*-\\s+listen:\\s*(\\d+)", java.util.regex.Pattern.MULTILINE)
|
||||||
|
.matcher(yamlContent);
|
||||||
|
if (m.find()) {
|
||||||
|
int pagePort = Integer.parseInt(m.group(1));
|
||||||
|
pageAddr = "http://127.0.0.1:" + pagePort;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("读取代理配置失败,使用默认页面地址: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
loadPlaygroundParsers(pageAddr);
|
||||||
System.out.println("启动成功: \n本地服务地址: " + addr);
|
System.out.println("启动成功: \n本地服务地址: " + addr);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -125,7 +148,7 @@ public class AppMain {
|
|||||||
/**
|
/**
|
||||||
* 在启动时加载所有已发布的演练场解析器
|
* 在启动时加载所有已发布的演练场解析器
|
||||||
*/
|
*/
|
||||||
private static void loadPlaygroundParsers() {
|
private static void loadPlaygroundParsers(String accessAddr) {
|
||||||
DbService dbService = AsyncServiceUtil.getAsyncServiceInstance(DbService.class);
|
DbService dbService = AsyncServiceUtil.getAsyncServiceInstance(DbService.class);
|
||||||
|
|
||||||
dbService.getPlaygroundParserList().onSuccess(result -> {
|
dbService.getPlaygroundParserList().onSuccess(result -> {
|
||||||
@@ -163,6 +186,7 @@ public class AppMain {
|
|||||||
} else {
|
} else {
|
||||||
log.info("未找到已发布的演练场解析器");
|
log.info("未找到已发布的演练场解析器");
|
||||||
}
|
}
|
||||||
|
log.info("服务已启动,可通过 {} 访问页面", accessAddr);
|
||||||
}).onFailure(e -> {
|
}).onFailure(e -> {
|
||||||
log.error("加载演练场解析器列表失败", e);
|
log.error("加载演练场解析器列表失败", e);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user