Merge branch 'fix_init_http' into 'master'

fix init http

See merge request integration-system/isp-gate-service!4
This commit is contained in:
yan komissarov committed 2020-01-23 18:18:38 +03:00
commit f1c597bde9
4 files changed
+21 -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 {
+17 -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)
@@ -44,6 +57,7 @@ func (s *httpSrv) Init(MaxRequestBodySize int64) {
func (s *httpSrv) Close() {
if s.srv != nil {
s.working = false
if err := s.srv.Shutdown(); err != nil {
log.Warn(log_code.WarnHttpServerShutdown, err)
}