From d2bef900bd5b85c0f8bee8a55eedbaa4df0111bb Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Wed, 15 Nov 2023 21:12:00 -0600 Subject: [PATCH] expose timeout variables --- backend/app/api/main.go | 3 +++ backend/internal/sys/config/conf.go | 5 ++++- docs/docs/quick-start.md | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/backend/app/api/main.go b/backend/app/api/main.go index 49cb00e..8dc733f 100644 --- a/backend/app/api/main.go +++ b/backend/app/api/main.go @@ -146,6 +146,9 @@ func run(cfg *config.Config) error { app.server = server.NewServer( server.WithHost(app.conf.Web.Host), server.WithPort(app.conf.Web.Port), + server.WithReadTimeout(app.conf.Web.ReadTimeout), + server.WithWriteTimeout(app.conf.Web.WriteTimeout), + server.WithIdleTimeout(app.conf.Web.IdleTimeout), ) log.Info().Msgf("Starting HTTP Server on %s:%s", app.server.Host, app.server.Port) diff --git a/backend/internal/sys/config/conf.go b/backend/internal/sys/config/conf.go index 6ece6c5..932affe 100644 --- a/backend/internal/sys/config/conf.go +++ b/backend/internal/sys/config/conf.go @@ -36,9 +36,12 @@ type DebugConf struct { } type WebConfig struct { - Port string `yaml:"port" conf:"default:7745"` + Port string `yaml:"port" conf:"default:7745"` Host string `yaml:"host"` MaxUploadSize int64 `yaml:"max_file_upload" conf:"default:10"` + ReadTimeout int `yaml:"read_timeout" conf:"default:10"` + WriteTimeout int `yaml:"write_timeout" conf:"default:10"` + IdleTimeout int `yaml:"idle_timeout" conf:"default:30"` } // New parses the CLI/Config file and returns a Config struct. If the file argument is an empty string, the diff --git a/docs/docs/quick-start.md b/docs/docs/quick-start.md index 8e8029a..8fa4e4d 100644 --- a/docs/docs/quick-start.md +++ b/docs/docs/quick-start.md @@ -62,6 +62,9 @@ volumes: | HBOX_OPTIONS_ALLOW_REGISTRATION | true | allow users to register themselves | | HBOX_OPTIONS_AUTO_INCREMENT_ASSET_ID | true | auto increments the asset_id field for new items | | HBOX_WEB_MAX_UPLOAD_SIZE | 10 | maximum file upload size supported in MB | +| HBOX_WEB_READ_TIMEOUT | 10 | Read timeout of HTTP sever | +| HBOX_WEB_WRITE_TIMEOUT | 10 | Write timeout of HTTP server | +| HBOX_WEB_IDLE_TIMEOUT | 30 | Idle timeout of HTTP server | | HBOX_STORAGE_DATA | /data/ | path to the data directory, do not change this if you're using docker | | HBOX_STORAGE_SQLITE_URL | /data/homebox.db?_fk=1 | sqlite database url, if you're using docker do not change this | | HBOX_LOG_LEVEL | info | log level to use, can be one of: trace, debug, info, warn, error, critical |