Files
spinifex/cmd/ecs-agent/main.go
T
joshsiv-mulga 59decbc25c refactor: move ECS agent implementation to the ECS agent tree
cmd/ecs-agent keeps process lifecycle: signal context, the separate New
and Run calls, both failure log lines, the exit and the ldflags-set
build version, now passed in through Config.AgentVersion.
agents/ecs/agent owns Config, LoadConfig and the agent.
2026-10-07 12:27:11 +10:00

40 lines
992 B
Go

// Command ecs-agent runs inside a Spinifex ECS container instance; the
// implementation is in agents/ecs/agent. This binary owns process lifecycle:
// signal handling, startup and run failure logging, and the exit code.
package main
import (
"context"
"log/slog"
"os"
"os/signal"
"syscall"
_ "github.com/mulgadc/bluebottle/pkg/fipsboot"
ecsagent "github.com/mulgadc/spinifex/spinifex/agents/ecs/agent"
)
// version is the agent build version, reported in the register message.
// Overridable via -ldflags "-X main.version=...".
var version = "dev"
func main() {
cfg := ecsagent.LoadConfig(ecsagent.DefaultEnvFile)
cfg.AgentVersion = version
agent, err := ecsagent.New(cfg)
if err != nil {
slog.Error("ecs-agent: startup failed", "err", err)
os.Exit(1)
}
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
if err := agent.Run(ctx); err != nil {
slog.Error("ecs-agent: run failed", "err", err)
os.Exit(1)
}
}