MM-22049: Add idle timeout to the HTTP server (#13788)

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Agniva De Sarker
2020-02-05 11:32:05 +05:30
committed by GitHub
parent bfaf4fa5dc
commit 435d43049f
2 changed files with 7 additions and 0 deletions

View File

@@ -515,6 +515,7 @@ func (s *Server) Start() error {
Handler: handler,
ReadTimeout: time.Duration(*s.Config().ServiceSettings.ReadTimeout) * time.Second,
WriteTimeout: time.Duration(*s.Config().ServiceSettings.WriteTimeout) * time.Second,
IdleTimeout: time.Duration(*s.Config().ServiceSettings.IdleTimeout) * time.Second,
ErrorLog: errStdLog,
}

View File

@@ -93,6 +93,7 @@ const (
SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE = ""
SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT = 300
SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT = 300
SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT = 60
SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS = 10
SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM = ""
SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS = ":8065"
@@ -256,6 +257,7 @@ type ServiceSettings struct {
TrustedProxyIPHeader []string `restricted:"true"`
ReadTimeout *int `restricted:"true"`
WriteTimeout *int `restricted:"true"`
IdleTimeout *int `restricted:"true"`
MaximumLoginAttempts *int `restricted:"true"`
GoroutineHealthThreshold *int `restricted:"true"`
GoogleDeveloperKey *string `restricted:"true"`
@@ -459,6 +461,10 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
s.WriteTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT)
}
if s.IdleTimeout == nil {
s.IdleTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_IDLE_TIMEOUT)
}
if s.MaximumLoginAttempts == nil {
s.MaximumLoginAttempts = NewInt(SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS)
}