mirror of
https://github.com/lightninglabs/aperture.git
synced 2026-01-31 07:04:26 +01:00
config: add new config values for read, write and idle timeout
This commit is contained in:
10
aperture.go
10
aperture.go
@@ -379,11 +379,15 @@ func (a *Aperture) Start(errChan chan error) error {
|
||||
a.httpsServer = &http.Server{
|
||||
Addr: a.cfg.ListenAddr,
|
||||
Handler: handler,
|
||||
IdleTimeout: time.Minute * 2,
|
||||
ReadTimeout: time.Second * 15,
|
||||
WriteTimeout: time.Second * 30,
|
||||
IdleTimeout: a.cfg.IdleTimeout,
|
||||
ReadTimeout: a.cfg.ReadTimeout,
|
||||
WriteTimeout: a.cfg.WriteTimeout,
|
||||
}
|
||||
|
||||
log.Infof("Creating server with idle_timeout=%v, read_timeout=%v "+
|
||||
"and write_timeout=%v", a.cfg.IdleTimeout, a.cfg.ReadTimeout,
|
||||
a.cfg.WriteTimeout)
|
||||
|
||||
// Create TLS configuration by either creating new self-signed certs or
|
||||
// trying to obtain one through Let's Encrypt.
|
||||
var serveFn func() error
|
||||
|
||||
20
config.go
20
config.go
@@ -30,6 +30,12 @@ var (
|
||||
)
|
||||
)
|
||||
|
||||
const (
|
||||
defaultIdleTimeout = time.Minute * 2
|
||||
defaultReadTimeout = time.Second * 15
|
||||
defaultWriteTimeout = time.Second * 30
|
||||
)
|
||||
|
||||
type EtcdConfig struct {
|
||||
Host string `long:"host" description:"host:port of an active etcd instance"`
|
||||
User string `long:"user" description:"user authorized to access the etcd host"`
|
||||
@@ -202,6 +208,17 @@ type Config struct {
|
||||
|
||||
// Profile is the port on which the pprof profile will be served.
|
||||
Profile uint16 `long:"profile" description:"Enable HTTP profiling on given port -- NOTE port must be between 1024 and 65535"`
|
||||
|
||||
// IdleTimeout is the maximum amount of time a connection may be idle.
|
||||
IdleTimeout time.Duration `long:"idletimeout" description:"The maximum amount of time a connection may be idle before being closed."`
|
||||
|
||||
// ReadTimeout is the maximum amount of time to wait for a request to
|
||||
// be fully read.
|
||||
ReadTimeout time.Duration `long:"readtimeout" description:"The maximum amount of time to wait for a request to be fully read."`
|
||||
|
||||
// WriteTimeout is the maximum amount of time to wait for a response to
|
||||
// be fully written.
|
||||
WriteTimeout time.Duration `long:"writetimeout" description:"The maximum amount of time to wait for a response to be fully written."`
|
||||
}
|
||||
|
||||
func (c *Config) validate() error {
|
||||
@@ -237,5 +254,8 @@ func NewConfig() *Config {
|
||||
Tor: &TorConfig{},
|
||||
HashMail: &HashMailConfig{},
|
||||
Prometheus: &PrometheusConfig{},
|
||||
IdleTimeout: defaultIdleTimeout,
|
||||
ReadTimeout: defaultReadTimeout,
|
||||
WriteTimeout: defaultWriteTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user