fix init http

This commit is contained in:
DeniskaRediska committed 2020-01-23 17:46:39 +03:00
1 parent 50a7e32b48
commit 3f8e03eda4
4 files changed
+20 -8

No files matched your search

+16 -3
View File
@@ -1,6 +1,7 @@
package server
import (
"github.com/integration-system/go-cmp/cmp"
"github.com/integration-system/isp-lib/config"
log "github.com/integration-system/isp-log"
"github.com/valyala/fasthttp"
@@ -14,12 +15,24 @@ import (
var Http = &httpSrv{mx: sync.Mutex{}}
type httpSrv struct {
srv *fasthttp.Server
mx sync.Mutex
working bool
srv *fasthttp.Server
mx sync.Mutex
}
func (s *httpSrv) Init(MaxRequestBodySize int64) {
func (s *httpSrv) Init(new, old conf.HttpSetting) {
if s.working {
if !cmp.Equal(new, old) {
s.run(new.GetMaxRequestBodySize())
}
} else {
s.run(new.GetMaxRequestBodySize())
}
}
func (s *httpSrv) run(MaxRequestBodySize int64) {
s.mx.Lock()
s.working = true
if s.srv != nil {
if err := s.srv.Shutdown(); err != nil {
log.Warn(log_code.WarnHttpServerShutdown, err)