diff options
author | Valery Piashchynski <[email protected]> | 2020-03-26 19:27:16 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-03-26 19:27:16 +0300 |
commit | cbde9a2001657ae6a8e73e1a01dad6e660c2fc0a (patch) | |
tree | bcaff1553c179f0e8db5159c5b692cf5de908e11 /service/health | |
parent | 7b2e5d9ffcffd539cbff431855b775f1f8901f73 (diff) |
Update servers timeouts and max header sizes [health, metrics]
Diffstat (limited to 'service/health')
-rw-r--r-- | service/health/service.go | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/service/health/service.go b/service/health/service.go index c82f43b5..ce127340 100644 --- a/service/health/service.go +++ b/service/health/service.go @@ -6,12 +6,17 @@ import ( "github.com/sirupsen/logrus" "net/http" "sync" + "time" rrhttp "github.com/spiral/roadrunner/service/http" ) -// ID declares the public service name -const ID = "health" +const ( + // ID declares public service name. + ID = "health" + // maxHeaderSize declares max header size for prometheus server + maxHeaderSize = 1024 * 1024 * 100 // 104MB +) // Service to serve an endpoint for checking the health of the worker pool type Service struct { @@ -39,15 +44,23 @@ func (s *Service) Init(cfg *Config, r *rrhttp.Service, log *logrus.Logger) (bool func (s *Service) Serve() error { // Configure and start the http server s.mu.Lock() - s.http = &http.Server{Addr: s.cfg.Address, Handler: s} + s.http = &http.Server{ + Addr: s.cfg.Address, + Handler: s, + IdleTimeout: time.Hour * 24, + ReadTimeout: time.Minute * 60, + MaxHeaderBytes: maxHeaderSize, + ReadHeaderTimeout: time.Minute * 60, + WriteTimeout: time.Minute * 60, + } s.mu.Unlock() err := s.http.ListenAndServe() - if err == nil || err == http.ErrServerClosed { - return nil + if err != nil && err != http.ErrServerClosed { + return err } - return err + return nil } // Stop the health endpoint |