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

+1 -1
View File
@@ -1 +1 @@
2.5.1
2.5.2
+2
View File
@@ -1,3 +1,5 @@
## 2.5.2
* fix init http
## 2.5.1
* fix code response when doesn't match user id
* fix config reload
+1 -4
View File
@@ -2,7 +2,6 @@ package main
import (
"context"
"github.com/integration-system/go-cmp/cmp"
"github.com/integration-system/isp-lib/bootstrap"
"github.com/integration-system/isp-lib/config"
"github.com/integration-system/isp-lib/config/schema"
@@ -71,9 +70,7 @@ func onRemoteConfigReceive(remoteConfig, oldRemoteConfig *conf.RemoteConfig) {
metric.InitHttpServer(remoteConfig.Metrics)
service.Metrics.Init()
if !cmp.Equal(remoteConfig.HttpSetting, oldRemoteConfig.HttpSetting) {
server.Http.Init(remoteConfig.HttpSetting.GetMaxRequestBodySize())
}
server.Http.Init(remoteConfig.HttpSetting, oldRemoteConfig.HttpSetting)
}
func socketConfiguration(cfg interface{}) structure.SocketConfiguration {
+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)