Handle missing Java service executable
This commit is contained in:
@@ -579,6 +579,16 @@ def _restart_backend(
|
||||
port = port if port is not None else _extract_server_port(command)
|
||||
if port is None:
|
||||
raise ValueError("后端启动命令缺少 -Dserver.port 配置")
|
||||
if popen is None and not _launch_executable_exists(command[0]):
|
||||
executable = command[0]
|
||||
if Path(executable).name.lower() in {"java", "java.exe"}:
|
||||
on_output(
|
||||
"未找到 Java 启动程序。请在“安装环境”中安装 JDK,"
|
||||
"或点击 JDK 的“选择路径”选择 JDK 根目录或 bin\\java.exe,然后重新检测环境。"
|
||||
)
|
||||
else:
|
||||
on_output(f"未找到服务启动程序: {executable}")
|
||||
return 1
|
||||
replace_listeners = replace_listeners or _replace_port_listeners
|
||||
if not replace_listeners(port, on_output):
|
||||
on_output(f"端口 {port} 未能在限定时间内释放,后端未启动。")
|
||||
@@ -644,6 +654,13 @@ def _restart_backend(
|
||||
return 1
|
||||
|
||||
|
||||
def _launch_executable_exists(executable: str) -> bool:
|
||||
path = Path(executable)
|
||||
if path.is_absolute() or any(separator in executable for separator in ("/", "\\")):
|
||||
return path.is_file()
|
||||
return shutil.which(executable) is not None
|
||||
|
||||
|
||||
def _service_console_launcher() -> list[str]:
|
||||
if getattr(sys, "frozen", False):
|
||||
return [sys.executable, "--service-console"]
|
||||
|
||||
Reference in New Issue
Block a user