From ae8af5413143636d5fe52ddaffa5d9122681bc20 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sun, 7 Feb 2021 18:40:11 +0300 Subject: Update config Endure updated to beta.23 Tests update --- plugins/http/plugin.go | 28 +++++++++++++++------------- plugins/server/plugin.go | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'plugins') diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go index 3672f5ac..ff0c1c30 100644 --- a/plugins/http/plugin.go +++ b/plugins/http/plugin.go @@ -102,19 +102,6 @@ func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, server server.Se } s.cfg.Env[RR_MODE] = "http" - - s.pool, err = server.NewWorkerPool(context.Background(), pool.Config{ - Debug: s.cfg.Pool.Debug, - NumWorkers: s.cfg.Pool.NumWorkers, - MaxJobs: s.cfg.Pool.MaxJobs, - AllocateTimeout: s.cfg.Pool.AllocateTimeout, - DestroyTimeout: s.cfg.Pool.DestroyTimeout, - Supervisor: s.cfg.Pool.Supervisor, - }, s.cfg.Env, s.logCallback) - if err != nil { - return errors.E(op, err) - } - s.server = server return nil @@ -141,6 +128,19 @@ func (s *Plugin) Serve() chan error { errCh := make(chan error, 2) var err error + s.pool, err = s.server.NewWorkerPool(context.Background(), pool.Config{ + Debug: s.cfg.Pool.Debug, + NumWorkers: s.cfg.Pool.NumWorkers, + MaxJobs: s.cfg.Pool.MaxJobs, + AllocateTimeout: s.cfg.Pool.AllocateTimeout, + DestroyTimeout: s.cfg.Pool.DestroyTimeout, + Supervisor: s.cfg.Pool.Supervisor, + }, s.cfg.Env, s.logCallback) + if err != nil { + errCh <- errors.E(op, err) + return errCh + } + s.handler, err = NewHandler( s.cfg.MaxRequestSize, *s.cfg.Uploads, @@ -303,6 +303,8 @@ func (s *Plugin) ServeHTTP(w http.ResponseWriter, r *http.Request) { // Workers returns associated pool workers func (s *Plugin) Workers() []worker.BaseProcess { + s.Lock() + defer s.Unlock() workers := s.pool.Workers() baseWorkers := make([]worker.BaseProcess, 0, len(workers)) for i := 0; i < len(workers); i++ { diff --git a/plugins/server/plugin.go b/plugins/server/plugin.go index 99d93d19..3fc77926 100644 --- a/plugins/server/plugin.go +++ b/plugins/server/plugin.go @@ -51,7 +51,7 @@ func (server *Plugin) Init(cfg config.Configurer, log logger.Logger) error { server.factory, err = server.initFactory() if err != nil { - return errors.E(err) + return errors.E(op, err) } return nil -- cgit v1.2.3