mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-09-18 15:08:21 +03:00
create register agent in agent
This commit is contained in:
@@ -1,16 +1,19 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
standartlog "log"
|
||||
|
||||
"github.com/docker/docker/client"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/agent/rpc"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/agent_service"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/collector"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/docker_service"
|
||||
"github.com/lorsanstand/HomeOps-Hub/internal/agent/utils/config_yaml"
|
||||
log2 "github.com/lorsanstand/HomeOps-Hub/internal/shared/log"
|
||||
"github.com/rs/zerolog"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
@@ -20,6 +23,7 @@ type App struct {
|
||||
}
|
||||
|
||||
func NewApp() *App {
|
||||
|
||||
cfg, err := config_yaml.NewConfig()
|
||||
if err != nil {
|
||||
standartlog.Fatalf("failed get config: %v", err)
|
||||
@@ -31,7 +35,9 @@ func NewApp() *App {
|
||||
}
|
||||
|
||||
func (a *App) Run() {
|
||||
GRPCConn, err := grpc.NewClient(a.cfg.GetGRPCAddress())
|
||||
ctx := context.Background()
|
||||
|
||||
GRPCConn, err := grpc.NewClient(a.cfg.GetGRPCAddress(), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
a.log.Error().Err(err).Msg("failed to get hub connections")
|
||||
return
|
||||
@@ -50,7 +56,8 @@ func (a *App) Run() {
|
||||
DockerService = docker_service.NewDockerService(DockerClient, a.log)
|
||||
}
|
||||
|
||||
Collector := collector.NewCollector(DockerService, a.log)
|
||||
collect := collector.NewCollector(DockerService, a.log)
|
||||
|
||||
Collector.GatherInfoSystem()
|
||||
agent := agent_service.NewAgentService(collect, conn, "", a.cfg, a.log)
|
||||
agent.RegisterAgentConn(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user