diff --git a/FU.pm b/FU.pm index ce830a6..25db727 100644 --- a/FU.pm +++ b/FU.pm @@ -507,7 +507,7 @@ sub _spawn { $c{proc} = $1 if /^--proc=([0-9]+)$/; $c{monitor} = 1 if /^--monitor$/; $c{monitor} = 0 if /^--no-monitor$/; - $c{max_reqs} = $1 if /^--max-reqs=([0-9]+)$/; + $c{max_reqs} = $1 if /^--max-reqs=([0-9]+(?::[0-9]+)?)$/; debug 1 if /^--debug$/; debug 0 if /^--no-debug$/; $ENV{FU_LOG_FILE} = $1 if /^--log-file=(.+)$/; @@ -553,6 +553,7 @@ sub _spawn { _supervisor \%c; } else { $c{supervisor_sock}->syswrite('r'.pack 'V', $$) if $c{supervisor_sock}; + $c{max_reqs} = $1 >= $2 ? $1 : $1 + int rand $2-$1 if $c{max_reqs} =~ /^([0-9]+):([0-9]+)$/; _run_loop \%c; } } @@ -1387,12 +1388,19 @@ significant cost in performance - better not enable this in production. =item FU_MAX_REQS=n +=item FU_MAX_REQS=min:max + =item --max-reqs=n +=item --max-reqs=min:max + Worker processes can automatically restart after handling a number of requests. -Set to 0 (the default) to disable this feature. This option can be useful when -your worker processes keep accumulating memory over time. A little pruning now -and then can never hurt. +Set to 0 (the default) to disable this feature. When set as C, the +number of requests is randomized in the given range, which is useful to avoid +restarting all worker processes around the same time. + +This option can be useful when your worker processes keep accumulating memory +over time. A little pruning now and then can never hurt. =item FU_DEBUG=0/1