feat: big ahh commit
- agent+proto+backend: transfer service status - agent: fix returning empty message on nonzero exit status - backend: refactor collector+commander and handlers dependent on them: implement agent accounting via grpc stats handler
This commit is contained in:
+15
-6
@@ -82,10 +82,13 @@ func main() {
|
||||
}()
|
||||
}
|
||||
|
||||
// Initialize Collector gRPC service
|
||||
coll := collector.New(logRepo)
|
||||
// Initialize Collector (log streaming) with its own ConnTracker
|
||||
collTracker := collector.NewConnTracker()
|
||||
coll := collector.New(logRepo, collTracker)
|
||||
|
||||
cmdr := commander.New(jobRepo)
|
||||
// Initialize ConnTracker for Commander agent lifecycle
|
||||
cmdTracker := commander.NewConnTracker()
|
||||
cmdr := commander.New(jobRepo, cmdTracker)
|
||||
|
||||
// Initialize script interpreter repository and service
|
||||
scriptRepo := repository.NewScriptInterpreterRepo(db)
|
||||
@@ -93,8 +96,9 @@ func main() {
|
||||
log.Printf("Warning: failed to initialize script interpreters table: %v", err)
|
||||
}
|
||||
scriptSvc := service.NewScriptServiceWithInterpreters(h.Repo, scriptRepo)
|
||||
scriptHandlers := handlers.NewScriptHandlers(scriptSvc, cmdr)
|
||||
jobsHandlers := handlers.NewJobsHandlers(cmdr, scriptSvc)
|
||||
scriptHandlers := handlers.NewScriptHandlers(scriptSvc, cmdTracker)
|
||||
jobsHandlers := handlers.NewJobsHandlers(cmdTracker, scriptSvc,
|
||||
os.Getenv("WHEREAMI") /* our address for redirects */)
|
||||
|
||||
// Initialize script management service and handlers
|
||||
scriptManageSvc := service.NewScriptService(h.Repo)
|
||||
@@ -201,6 +205,7 @@ func main() {
|
||||
jobsGroup.Use(auth.AuthMiddleware(), handlers.RequireAdmin())
|
||||
{
|
||||
jobsGroup.POST("", jobsHandlers.AddJob)
|
||||
jobsGroup.POST("/:id/wait", jobsHandlers.WaitJob)
|
||||
}
|
||||
|
||||
// Agent registration
|
||||
@@ -290,7 +295,11 @@ func main() {
|
||||
MinVersion: tls.VersionTLS12,
|
||||
}
|
||||
|
||||
grpcServer := grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsConfig)))
|
||||
grpcServer := grpc.NewServer(
|
||||
grpc.Creds(credentials.NewTLS(tlsConfig)),
|
||||
grpc.StatsHandler(collTracker),
|
||||
grpc.StatsHandler(cmdTracker),
|
||||
)
|
||||
proto.RegisterCommanderServer(grpcServer, cmdr)
|
||||
proto.RegisterCollectorServer(grpcServer, coll)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user