diff --git a/cmd/server/main.go b/cmd/server/main.go index a4a1a5a..4fe16d7 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -1,11 +1,11 @@ package main import ( + "fmt" "google.golang.org/grpc" "log" "net" "otel-trace-reciever/internal/config" - "otel-trace-reciever/internal/repository" "otel-trace-reciever/internal/server" "google.golang.org/grpc/reflection" @@ -15,7 +15,15 @@ import ( ) func main() { + grpcHost := "0.0.0.0" + grpcPort := 4317 + grpcAddress := fmt.Sprintf("%s:%d", grpcHost, grpcPort) + cfg, err := config.Load() + if err != nil { + log.Fatalf("Failed to load config: %v", err) + } + repo, err := repository.NewMongoRepository(cfg.MongoURI) if err != nil { log.Fatalf("Failed to create repository: %v", err) @@ -29,13 +37,13 @@ func main() { reflection.Register(grpcServer) - lis, err := net.Listen("tcp", "0.0.0.0:4317") + lis, err := net.Listen("tcp", grpcAddress) if err != nil { log.Fatalf("Failed to listen: %v", err) } - log.Println("gRPC server listening on 0.0.0.0:4317") + log.Printf("gRPC server listening on %s", grpcAddress) if err := grpcServer.Serve(lis); err != nil { log.Fatalf("Failed to serve: %v", err) } -} +} \ No newline at end of file