Refactor CLI: birdc-style help, collapsed nouns, ReloadConfig, bug fixes
maglevc - Rewrite '?' handler (birdc-style): show full command paths from current position to every leaf, right-aligned help column, dynamic slot values displayed as an indented block when cursor is at a slot position. - Collapse show frontends/frontend, backends/backend, healthchecks/healthcheck into single plural-noun nodes with an optional <name> slot. Allows 'sh ba' (list all) and 'sh ba nginx0' (show one) without ambiguity. - Add 'config reload' command. - Fix tabwriter ANSI alignment: continuation lines in transition output now carry the same label() byte overhead as the header line. - Fix broken Walk for 'set frontend' command: setFrontendPoolName and setWeightValue were fixed-word nodes that couldn't capture user input; mark them as slot nodes with dynNone. - Add tree_test.go covering expandPaths, cycle detection, prefix matching, and the full weight-command walk. gRPC / proto - Add ReloadConfig RPC: checks config then applies it to the running checker, returning ok/parse_error/semantic_error/reload_error. - Add logging to CheckConfig (config-check-start/config-check-done at INFO level). maglevd - SIGHUP handler now calls maglevServer.TriggerReload(), sharing the same code path as the gRPC ReloadConfig RPC. docs - Collapse show command documentation to use [<name>] optional syntax. - Remove developer-facing 'Command tree and parser' section. - Document 'config reload'.
This commit is contained in:
@@ -93,7 +93,8 @@ func run() error {
|
||||
return fmt.Errorf("listen %s: %w", *grpcAddr, err)
|
||||
}
|
||||
srv := grpc.NewServer()
|
||||
grpcapi.RegisterMaglevServer(srv, grpcapi.NewServer(ctx, chkr, logBroadcaster, *configPath))
|
||||
maglevServer := grpcapi.NewServer(ctx, chkr, logBroadcaster, *configPath)
|
||||
grpcapi.RegisterMaglevServer(srv, maglevServer)
|
||||
if *enableReflection {
|
||||
reflection.Register(srv)
|
||||
}
|
||||
@@ -112,21 +113,7 @@ func run() error {
|
||||
for sig := range sigCh {
|
||||
switch sig {
|
||||
case syscall.SIGHUP:
|
||||
slog.Info("config-reload-start")
|
||||
newCfg, result := config.Check(*configPath)
|
||||
if !result.OK() {
|
||||
if result.ParseError != "" {
|
||||
slog.Error("config-check-failed", "type", "parse", "err", result.ParseError)
|
||||
} else {
|
||||
slog.Error("config-check-failed", "type", "semantic", "err", result.SemanticError)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := chkr.Reload(ctx, newCfg); err != nil {
|
||||
slog.Error("checker-reload-error", "err", err)
|
||||
continue
|
||||
}
|
||||
slog.Info("config-reload-done", "frontends", len(newCfg.Frontends))
|
||||
maglevServer.TriggerReload()
|
||||
|
||||
case syscall.SIGTERM, syscall.SIGINT:
|
||||
slog.Info("shutdown", "signal", sig)
|
||||
|
||||
Reference in New Issue
Block a user