diff options
author | Dmitry Patsura <[email protected]> | 2019-06-13 21:03:15 +0300 |
---|---|---|
committer | Dmitry Patsura <[email protected]> | 2019-06-13 21:03:15 +0300 |
commit | a612f9d4ac8d2f5659a2e984067baf5a11fd6c2a (patch) | |
tree | c788a86b155b9f99c2a5d388e62fb89a99da58f6 /service/http/service.go | |
parent | 4d3b5a3fdd7750e7b6389fc7b4c92d56226e941e (diff) |
Feature: Allow to disable http, and use only FastCGI
Diffstat (limited to 'service/http/service.go')
-rw-r--r-- | service/http/service.go | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/service/http/service.go b/service/http/service.go index 967aa63b..b309cd45 100644 --- a/service/http/service.go +++ b/service/http/service.go @@ -69,6 +69,10 @@ func (s *Service) Init(cfg *Config, r *rpc.Service, e env.Environment) (bool, er } } + if !cfg.EnableHTTP() && !cfg.EnableTLS() && !cfg.EnableFCGI() { + return false, nil + } + return true, nil } @@ -94,7 +98,9 @@ func (s *Service) Serve() error { s.handler = &Handler{cfg: s.cfg, rr: s.rr} s.handler.Listen(s.throw) - s.http = &http.Server{Addr: s.cfg.Address, Handler: s} + if s.cfg.EnableHTTP() { + s.http = &http.Server{Addr: s.cfg.Address, Handler: s} + } if s.cfg.EnableTLS() { s.https = s.initSSL() @@ -113,9 +119,11 @@ func (s *Service) Serve() error { err := make(chan error, 3) - go func() { - err <- s.http.ListenAndServe() - }() + if s.http != nil { + go func() { + err <- s.http.ListenAndServe() + }() + } if s.https != nil { go func() { @@ -136,9 +144,6 @@ func (s *Service) Serve() error { func (s *Service) Stop() { s.mu.Lock() defer s.mu.Unlock() - if s.http == nil { - return - } if s.fcgi != nil { go s.fcgi.Shutdown(context.Background()) @@ -148,7 +153,9 @@ func (s *Service) Stop() { go s.https.Shutdown(context.Background()) } - go s.http.Shutdown(context.Background()) + if s.http != nil { + go s.http.Shutdown(context.Background()) + } } // Server returns associated rr server (if any). |