small pixel drawing of a pufferfish cascade

pass agent config errors up
Jes Olson j3s@c3f.net
Mon, 20 Feb 2023 15:24:33 -0800
commit

abafaa3ad00eeeadd0eab20ef9e1e9ca3ee5d981

parent

ac53842ad00701d7c2f94bc7b61f8309f4e7bf89

1 files changed, 8 insertions(+), 6 deletions(-)

jump to
M command/agent/agent.gocommand/agent/agent.go

@@ -19,8 +19,11 @@ // note that this value interacts with serf's LeavePropagateDelay config

const gracefulTimeout = 10 * time.Second func Run(args []string) { - // do flags - config := configureAgent() + config, err := configureAgent() + if err != nil { + fmt.Println(err) + os.Exit(1) + } agent := agent.New(config) if err := agent.Start(); err != nil { fmt.Println(err)

@@ -104,14 +107,13 @@

return nil } -func configureAgent() *agent.Config { +func configureAgent() (*agent.Config, error) { config := agent.DefaultConfig() // CASCADE_BIND=192.168.0.15:12345 if os.Getenv("CASCADE_BIND") != "" { err := parseFlagAddress(os.Getenv("CASCADE_BIND"), config.BindAddr) if err != nil { - fmt.Printf("Error parsing CASCADE_BIND: %s\n", err) - os.Exit(1) + return nil, err } } // CASCADE_JOIN=127.0.0.1,127.0.0.5

@@ -122,7 +124,7 @@ // CASCADE_NAME=nostromo.j3s.sh

if os.Getenv("CASCADE_NAME") != "" { config.NodeName = os.Getenv("CASCADE_NAME") } - return config + return config, nil } // parseFlagAddress takes a colon-delimited host:port pair as a string, parses