more fixes before final part
This commit is contained in:
@ -11,6 +11,7 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.dws.rip/dubey/kat/internal/agent"
|
||||
"git.dws.rip/dubey/kat/internal/api"
|
||||
"git.dws.rip/dubey/kat/internal/cli"
|
||||
"git.dws.rip/dubey/kat/internal/config"
|
||||
@ -265,7 +266,7 @@ func runInit(cmd *cobra.Command, args []string) {
|
||||
joinHandler := api.NewJoinHandler(etcdStore, caKeyPath, caCertPath)
|
||||
apiServer.RegisterJoinHandler(joinHandler)
|
||||
log.Printf("Registered join handler with CA key: %s, CA cert: %s", caKeyPath, caCertPath)
|
||||
|
||||
|
||||
// Register the node status handler
|
||||
nodeStatusHandler := api.NewNodeStatusHandler(etcdStore)
|
||||
apiServer.RegisterNodeStatusHandler(nodeStatusHandler)
|
||||
@ -343,11 +344,11 @@ func runJoin(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
log.Printf("Successfully joined cluster. Node is ready.")
|
||||
|
||||
|
||||
// Setup signal handling for graceful shutdown
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
|
||||
// Create and start the agent with heartbeating
|
||||
agent, err := agent.NewAgent(
|
||||
joinResp.NodeName,
|
||||
@ -360,19 +361,19 @@ func runJoin(cmd *cobra.Command, args []string) {
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create agent: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// Setup mTLS client
|
||||
if err := agent.SetupMTLSClient(); err != nil {
|
||||
log.Fatalf("Failed to setup mTLS client: %v", err)
|
||||
}
|
||||
|
||||
|
||||
// Start heartbeating
|
||||
if err := agent.StartHeartbeat(ctx); err != nil {
|
||||
log.Fatalf("Failed to start heartbeat: %v", err)
|
||||
}
|
||||
|
||||
|
||||
log.Printf("Node %s is now running with heartbeat. Press Ctrl+C to exit.", nodeName)
|
||||
|
||||
|
||||
// Wait for shutdown signal
|
||||
<-ctx.Done()
|
||||
log.Println("Received shutdown signal. Stopping heartbeat...")
|
||||
|
Reference in New Issue
Block a user