1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-09-16 09:36:18 +02:00

Add IMGPROXY_GRACEFUL_STOP_TIMEOUT config

This commit is contained in:
DarthSim
2025-09-08 20:32:23 +03:00
parent d02a678229
commit 7da78ef191
3 changed files with 12 additions and 2 deletions

View File

@@ -2,9 +2,11 @@
## [Unreleased]
### Added
- (pro) Add [color_profile](https://docs.imgproxy.net/latest/usage/processing#color-profile) processing option and [IMGPROXY_COLOR_PROFILES_DIR](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_COLOR_PROFILES_DIR) config
- Add [IMGPROXY_GRACEFUL_STOP_TIMEOUT](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_GRACEFUL_STOP_TIMEOUT) config.
- (pro) Add [color_profile](https://docs.imgproxy.net/latest/usage/processing#color-profile) processing option and [IMGPROXY_COLOR_PROFILES_DIR](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_COLOR_PROFILES_DIR) config.
### Changed
- Update the default graceful stop timeout to twice the [IMGPROXY_TIMEOUT](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_TIMEOUT) config value.
- (pro) Improve video decoding performance.
- (pro) Respond with `422 Unprocessable Entity` on error during video decoding.

View File

@@ -23,6 +23,7 @@ var (
Network string
Bind string
Timeout int
GracefulStopTimeout int
ReadRequestTimeout int
WriteResponseTimeout int
KeepAliveTimeout int
@@ -231,6 +232,7 @@ func Reset() {
Network = "tcp"
Bind = ":8080"
Timeout = 10
GracefulStopTimeout = 20
ReadRequestTimeout = 10
WriteResponseTimeout = 10
KeepAliveTimeout = 10
@@ -438,6 +440,9 @@ func Configure() error {
}
configurators.Int(&Timeout, "IMGPROXY_TIMEOUT")
GracefulStopTimeout = Timeout * 2
configurators.Int(&GracefulStopTimeout, "IMGPROXY_GRACEFUL_STOP_TIMEOUT")
if _, ok := os.LookupEnv("IMGPROXY_READ_TIMEOUT"); ok {
log.Warning("IMGPROXY_READ_TIMEOUT is deprecated, use IMGPROXY_READ_REQUEST_TIMEOUT instead")
configurators.Int(&ReadRequestTimeout, "IMGPROXY_READ_TIMEOUT")

View File

@@ -80,7 +80,10 @@ func startServer(cancel context.CancelFunc) (*http.Server, error) {
func shutdownServer(s *http.Server) {
log.Info("Shutting down the server...")
ctx, close := context.WithTimeout(context.Background(), 5*time.Second)
ctx, close := context.WithTimeout(
context.Background(),
time.Duration(config.GracefulStopTimeout)*time.Second,
)
defer close()
s.Shutdown(ctx)