Package standalone app and automate MySQL setup

This commit is contained in:
王鹏
2026-10-09 08:22:29 +08:00
parent d1695eba74
commit 0e7f52e26a
8 changed files with 67 additions and 9 deletions

View File

@@ -437,11 +437,9 @@ def _restart_backend(
log_file.write(f"\n\n===== 后端部署 {started_at},端口 {port} =====\n")
log_file.flush()
if os.name == "nt":
console_runner = Path(__file__).with_name("service_console.py")
process = popen(
[
sys.executable,
str(console_runner),
*_service_console_launcher(),
"--title",
f"后端服务 - 端口 {port}",
"--log",
@@ -488,6 +486,13 @@ def _restart_backend(
return 1
def _service_console_launcher() -> list[str]:
if getattr(sys, "frozen", False):
return [sys.executable, "--service-console"]
console_runner = Path(__file__).with_name("service_console.py")
return [sys.executable, str(console_runner)]
def _restart_ssm_backend(
command: list[str],
cwd: Path,

View File

@@ -366,10 +366,17 @@ class DeployWorkbench(tk.Tk):
except ValueError as exc:
messagebox.showwarning("暂不支持自动安装", str(exc))
return
mysql_note = ""
if tool_name == "MySQL":
mysql_note = (
"\n\n将安装 MySQL Community Server 及官方工具。首次安装后,请在部署配置中填写实际的 "
"root 用户密码;程序不会生成、保存或显示默认数据库密码。"
)
if not messagebox.askyesno(
f"确认安装 {tool_name}",
f"即将通过 winget 安装 {tool_name}。\n\n"
f"命令: {' '.join(command)}\n\n"
f"命令: {' '.join(command)}"
f"{mysql_note}\n\n"
"安装可能需要管理员权限,并可能修改 PATH。是否继续?",
):
return

View File

@@ -76,7 +76,16 @@ def build_install_command(tool_name: str, version: str | None = None) -> list[st
package_id = WINGET_PACKAGES.get(tool_name)
if not package_id:
raise ValueError(f"\u4e0d\u652f\u6301\u81ea\u52a8\u5b89\u88c5: {tool_name}")
return ["winget", "install", "-e", "--id", package_id]
return [
"winget",
"install",
"--exact",
"--id",
package_id,
"--accept-source-agreements",
"--accept-package-agreements",
"--disable-interactivity",
]
def default_maven_install_root() -> Path: