From 90aea4f58d1cd1beecb0788039f5a9564c86a977 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Tue, 9 Mar 2021 22:58:18 +0100 Subject: [PATCH] tweak proxy scalability --- ocis/pkg/command/run.go | 3 ++- ocis/pkg/runtime/service/service.go | 4 +--- proxy/pkg/command/server.go | 7 +++++-- proxy/pkg/metrics/metrics.go | 20 ++++---------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ocis/pkg/command/run.go b/ocis/pkg/command/run.go index 0850356986..ae45e7dc7e 100644 --- a/ocis/pkg/command/run.go +++ b/ocis/pkg/command/run.go @@ -5,6 +5,7 @@ import ( "log" "net" "net/rpc" + "os" cli "github.com/micro/cli/v2" @@ -38,7 +39,7 @@ func RunCommand(cfg *config.Config) *cli.Command { var reply int - if err := client.Call("Service.Start", "settings", &reply); err != nil { + if err := client.Call("Service.Start", os.Args[2], &reply); err != nil { log.Fatal(err) } fmt.Println(reply) diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 908a9af19c..8baef87a15 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -169,7 +169,6 @@ func (s *Service) Start(name string, reply *int) error { return nil } s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, s.cfg))) - //s.serviceToken["settings"] = append(s.serviceToken[name], s.Supervisor.Add(settings.NewSutureService(s.context, s.cfg))) *reply = 0 return nil } @@ -183,12 +182,11 @@ func (s *Service) List(args struct{}, reply *string) error { func (s *Service) Kill(name string, reply *int) error { if len(s.serviceToken[name]) > 0 { for i := range s.serviceToken[name] { - fmt.Printf("\n\n%s\n%+v\n\n", name, s.serviceToken[name]) if err := s.Supervisor.Remove(s.serviceToken[name][i]); err != nil { return err } - delete(s.serviceToken, name) } + delete(s.serviceToken, name) } else { return fmt.Errorf("service %s not found", name) } diff --git a/proxy/pkg/command/server.go b/proxy/pkg/command/server.go index d8cfc56e94..3b738837f6 100644 --- a/proxy/pkg/command/server.go +++ b/proxy/pkg/command/server.go @@ -154,6 +154,10 @@ func Server(cfg *config.Config) *cli.Command { Msg("Tracing is not enabled") } + var ( + m = metrics.New() + ) + stop := make(chan os.Signal, 1) gr := run.Group{} ctx, cancel := func() (context.Context, context.CancelFunc) { @@ -162,7 +166,6 @@ func Server(cfg *config.Config) *cli.Command { } return context.WithCancel(cfg.Context) }() - m := metrics.New() defer cancel() @@ -179,7 +182,7 @@ func Server(cfg *config.Config) *cli.Command { proxyHTTP.Logger(logger), proxyHTTP.Context(ctx), proxyHTTP.Config(cfg), - proxyHTTP.Metrics(m), + proxyHTTP.Metrics(metrics.New()), proxyHTTP.Middlewares(loadMiddlewares(ctx, logger, cfg)), ) diff --git a/proxy/pkg/metrics/metrics.go b/proxy/pkg/metrics/metrics.go index 068bfc7a0d..d3cb55f750 100644 --- a/proxy/pkg/metrics/metrics.go +++ b/proxy/pkg/metrics/metrics.go @@ -49,22 +49,10 @@ func New() *Metrics { }, []string{"versions"}), } - mustNotFail(prometheus.Register( - m.Counter, - )) - - mustNotFail(prometheus.Register( - m.Latency, - )) - - mustNotFail(prometheus.Register( - m.Duration, - )) - - mustNotFail(prometheus.Register( - m.BuildInfo, - )) - + prometheus.Register(m.Counter) + prometheus.Register(m.Latency) + prometheus.Register(m.Duration) + prometheus.Register(m.BuildInfo) return m }