From f69217d210d6a04c7ec3b648bcd6441f3ecc97e3 Mon Sep 17 00:00:00 2001 From: Pavel Tatarskiy Date: Wed, 25 Dec 2024 23:12:51 +0300 Subject: [PATCH] make pprof and probe optional --- serve.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/serve.go b/serve.go index 4ff4708..52fb815 100644 --- a/serve.go +++ b/serve.go @@ -43,13 +43,21 @@ func serve(c *cli.Context) (err error) { return } + var servers []cs.Servable + // Setting Probe probe := cs.NewProbe(c) - defer probe.Close() + if probe != nil { + servers = append(servers, probe) + defer probe.Close() + } // Setting Pprof pprof := cs.NewPprof(c) - defer pprof.Close() + if pprof != nil { + servers = append(servers, pprof) + defer pprof.Close() + } var providers []s.StoreProvider @@ -107,10 +115,11 @@ func serve(c *cli.Context) (err error) { // Setting GRPC Server grpcServer := s.NewGRPCServer(c, server) + servers = append(servers, grpcServer) defer grpcServer.Close() // Setting ServeService - serve := cs.NewServe(probe, pprof, grpcServer) + serve := cs.NewServe(servers...) // And SERVE! err = serve.Serve()