timeout values now in config
This commit is contained in:
+8
-3
@@ -167,7 +167,12 @@ type AmConfig struct {
|
||||
} `yaml:"posting"`
|
||||
Tuning struct {
|
||||
WorkerTasks int `yaml:"workerTasks"`
|
||||
Queues struct {
|
||||
Timeouts struct {
|
||||
HttpRead int `yaml:"httpRead"`
|
||||
HttpWrite int `yaml:"httpWrite"`
|
||||
HttpIdle int `yaml:"httpIdle"`
|
||||
} `yaml:"timeouts"`
|
||||
Queues struct {
|
||||
AuditWrites int `yaml:"auditWrites"`
|
||||
ContextRecycle int `yaml:"contextRecycle"`
|
||||
EmailRecycle int `yaml:"emailRecycle"`
|
||||
@@ -200,7 +205,7 @@ func (c *AmConfig) ExPath(path string) string {
|
||||
return filepath.Join(c.baseDir, path)
|
||||
}
|
||||
|
||||
// AmConfigComputed is the configuration values which are "computed" based only on values in AmConfig.
|
||||
// AmConfigComputed is the configuration values which are "computed" based only on values in AmConfig and CommandLine.
|
||||
type AmConfigComputed struct {
|
||||
DebugMode bool // are we in debug mode?
|
||||
LogLevel string // the logging level
|
||||
@@ -321,7 +326,7 @@ func overlayStructValue(dest, loaded, defaults reflect.Value) {
|
||||
}
|
||||
} else {
|
||||
// if we see this message, this function needs more work
|
||||
log.Errorf("*** unable to deal with field %s of type %s", structField.Name, typ.Name())
|
||||
log.Fatalf("*** unable to deal with field %s of type %s", structField.Name, typ.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,10 @@ posting:
|
||||
- "image/png"
|
||||
tuning:
|
||||
workerTasks: 4
|
||||
timeouts:
|
||||
httpRead: 30
|
||||
httpWrite: 30
|
||||
httpIdle: 120
|
||||
queues:
|
||||
auditWrites: 16
|
||||
contextRecycle: 16
|
||||
|
||||
@@ -37,6 +37,9 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// READ_HEADER_TIMEOUT is the timeout value for reading headers in seconds. (Deliberately NOT configurable because this is a security issue)
|
||||
const READ_HEADER_TIMEOUT = 2
|
||||
|
||||
// GetAndPost is used to have functions that respond to both GET and POST on a URI.
|
||||
var GetAndPost = []string{http.MethodGet, http.MethodPost}
|
||||
|
||||
@@ -214,7 +217,7 @@ func setupEcho() *echo.Echo {
|
||||
// ampool is the worker pool for one-shot background tasks.
|
||||
var ampool *util.WorkerPool
|
||||
|
||||
// SystemStartTime records the time since the system was started.
|
||||
// SystemStartTime records the time the system was started.
|
||||
var SystemStartTime time.Time
|
||||
|
||||
// main is Ye Olde Main Function.
|
||||
@@ -273,10 +276,10 @@ func main() {
|
||||
log.Fatalf("error in shutting down the server: %v", err)
|
||||
},
|
||||
BeforeServeFunc: func(s *http.Server) error {
|
||||
s.ReadTimeout = 30 * time.Second
|
||||
s.WriteTimeout = 30 * time.Second
|
||||
s.IdleTimeout = 120 * time.Second
|
||||
s.ReadHeaderTimeout = 2 * time.Second
|
||||
s.ReadTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpRead) * time.Second
|
||||
s.WriteTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpWrite) * time.Second
|
||||
s.IdleTimeout = time.Duration(config.GlobalConfig.Tuning.Timeouts.HttpIdle) * time.Second
|
||||
s.ReadHeaderTimeout = READ_HEADER_TIMEOUT * time.Second
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user