Files
headplane/cmd/hp_agent/hp_agent.go
T
2025-06-16 11:45:25 -04:00

36 lines
620 B
Go

package main
import (
_ "github.com/joho/godotenv/autoload"
"github.com/tale/headplane/internal/config"
"github.com/tale/headplane/internal/hpagent"
"github.com/tale/headplane/internal/tsnet"
"github.com/tale/headplane/internal/util"
)
type Register struct {
Type string
ID string
}
func main() {
log := util.GetLogger()
cfg, err := config.Load()
if err != nil {
log.Fatal("Failed to load config: %s", err)
}
log.SetDebug(cfg.Debug)
agent := tsnet.NewAgent(cfg)
agent.Connect()
defer agent.Shutdown()
log.Msg(&Register{
Type: "register",
ID: agent.ID,
})
hpagent.FollowMaster(agent)
}