fix(gateway): avoid restarting stopped systemd services

This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-10 23:47:23 +08:00
1 parent 62c05e7f7e
commit 0ce335bf12
5 files changed
+16 -10

No files matched your search

+6 -6
View File
@@ -180,11 +180,11 @@ def create_gateway_app(
):
console.print(
"[yellow]Gateway is already running in the foreground; "
"an attached process cannot be detached in place.[/yellow]"
"it cannot be detached in place.[/yellow]"
)
console.print(
"[dim]Stop it in its current terminal, then run "
"`nanobot gateway --background`.[/dim]"
"[dim]Stop it with its service manager if supervised, or use "
"`nanobot gateway stop`; then run `nanobot gateway --background`.[/dim]"
)
print_status(result.status)
raise typer.Exit(1)
@@ -329,12 +329,12 @@ def create_gateway_app(
raise typer.Exit(1)
if result.message == "gateway_foreground_restart_required":
console.print(
"[yellow]Gateway is attached to a foreground terminal and cannot "
"[yellow]Gateway is running in the foreground and cannot "
"be restarted as a background process.[/yellow]"
)
console.print(
"[dim]Restart it in that terminal, or stop it and run "
"`nanobot gateway --background`.[/dim]"
"[dim]Restart it with its service manager if supervised, or stop it "
"and run `nanobot gateway --background`.[/dim]"
)
print_status(result.status)
raise typer.Exit(1)
+2 -1
View File
@@ -266,7 +266,8 @@ def _systemd_unit_content(
"Type=simple",
f"WorkingDirectory={_systemd_quote(str(working_directory))}",
f"ExecStart={quoted_command}",
"Restart=always",
"Restart=on-failure",
"SuccessExitStatus=SIGTERM",
"RestartSec=10",
"Environment=PYTHONUNBUFFERED=1",
"NoNewPrivileges=yes",