The console gains live views of nodes, GPUs, models, replicas, usage and agent logs, and a settings tree over every key of server.yaml (agent.yaml on a node), generated from the configuration structs: values with their defaults and doc comments, edited in dialogs, saved only once the service's own loader accepts them, comments kept. The generator now tells blocks apart by package, which brings the TLS, engine and supervisor settings back into the reference. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package cli
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"runtime"
|
|
|
|
"github.com/mattn/go-isatty"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// A bare `llmgw` in a terminal: the setup screens on a machine with nothing
|
|
// installed, the console on a control plane. Anywhere else — a pipe, a
|
|
// script, another operating system — it prints its help, as it always did.
|
|
|
|
func interactive(cmd *cobra.Command) bool {
|
|
return isTerminal(cmd.OutOrStdout()) && isatty.IsTerminal(os.Stdin.Fd())
|
|
}
|
|
|
|
func runHome(cmd *cobra.Command) error {
|
|
out := cmd.OutOrStdout()
|
|
if runtime.GOOS != "linux" {
|
|
fmt.Fprintln(out, "The setup and console screens run on the Linux machine they manage.")
|
|
fmt.Fprintln(out)
|
|
return cmd.Help()
|
|
}
|
|
if os.Geteuid() != 0 {
|
|
return errors.New("run it as root — sudo llmgw — since it installs software and holds the certificate authority")
|
|
}
|
|
switch {
|
|
// Installed is the service in place, not only its configuration: a setup
|
|
// that stopped halfway has written server.yaml and nothing that runs, and
|
|
// the setup screens are what finish it.
|
|
case exists("/etc/llmgw/server.yaml") && exists("/etc/systemd/system/llmgw-server.service"):
|
|
return runConsole(cmd.Context(), out, "/etc/llmgw/server.yaml")
|
|
case exists("/etc/llmgw/agent.yaml"):
|
|
// A node: its own settings. The cluster is watched from the
|
|
// control plane.
|
|
return runConsole(cmd.Context(), out, "/etc/llmgw/agent.yaml")
|
|
}
|
|
return runSetupTUI(cmd.Context(), out)
|
|
}
|
|
|
|
func exists(p string) bool {
|
|
_, err := os.Stat(p)
|
|
return err == nil
|
|
}
|