Files
Ilker ManapandClaude Opus 5.5 7245dbe1dd llmgw stop, start and restart act on the whole system
Issue #3 asked for commands to stop and start the system, and 05aa21c gave
only one machine's services. Now:

- llmgw stop sets serving.stopped in the cluster's settings, live: the
  reconciler wants every model at no replicas, freeing every GPU, and the
  gateway answers every POST under /v1/ with 503 system_stopped. The control
  planes, agents and mirror keep running, and no model's definition changes.
- llmgw start clears it; every model is placed again as it asks.
- llmgw restart has every agent restart over its stream (RestartAgent), then
  the other control planes over ssh, standbys before a leader, then this
  one; engines keep serving.
- llmgw status is the cluster's summary, saying when it is stopped.

One machine's services moved to llmgw service status|start|stop|restart.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-07 18:01:45 +02:00

74 lines
1.8 KiB
Go

// Package cli builds llmgw's command line surface.
package cli
import (
"log/slog"
"github.com/spf13/cobra"
"gitea.mynodes.xyz/ilker/llmgw/internal/obs"
"gitea.mynodes.xyz/ilker/llmgw/internal/version"
)
type globalFlags struct {
logLevel string
logFormat string
}
var global globalFlags
// Root returns the root command with all subcommands attached.
func Root() *cobra.Command {
root := &cobra.Command{
Use: "llmgw",
Short: "LLM gateway for multi-fabric InfiniBand and heterogeneous GPU clusters",
Long: "llmgw serves LLMs running on your own GPU servers behind a single\n" +
"OpenAI-compatible endpoint. One binary, different roles per subcommand.",
Version: version.Version,
SilenceUsage: true,
SilenceErrors: true,
PersistentPreRun: func(_ *cobra.Command, _ []string) {
obs.Setup(obs.Options{Level: global.logLevel, Format: global.logFormat})
},
// Bare, in a terminal: the setup screens or the console. Otherwise
// the help, as before.
RunE: func(cmd *cobra.Command, _ []string) error {
if interactive(cmd) {
return runHome(cmd)
}
return cmd.Help()
},
}
pf := root.PersistentFlags()
pf.StringVar(&global.logLevel, "log-level", "info", "log level: debug|info|warn|error")
pf.StringVar(&global.logFormat, "log-format", "text", "log format: text|json")
root.AddCommand(
newServerCmd(),
newAgentCmd(),
newCtlCmd(),
newTenancyCmd(),
newUsersCmd(),
newOrgCmd(),
newMirrorCmd(),
newBundleCmd(),
newSimEngineCmd(),
newDoctorCmd(),
newNodeCmd(),
newSelfUpgradeCmd(),
newReleaseCmd(),
newJoinCmd(),
newFirewallCmd(),
newWipeCmd(),
newDocsCmd(),
)
// status, start, stop and restart: the whole system; service: this
// machine's services.
root.AddCommand(newSystemCmds()...)
root.AddCommand(newServiceCmd())
return root
}
func logger() *slog.Logger { return slog.Default() }