From 78d62e975b18c5f764d4bc30381391c45510ce0b Mon Sep 17 00:00:00 2001 From: Jori Hardman Date: Fri, 15 Jul 2016 12:03:44 -0500 Subject: [PATCH] Allow persistent_timeout to be configured via the dsl. --- lib/puma/configuration.rb | 3 ++- lib/puma/dsl.rb | 7 +++++++ lib/puma/server.rb | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/puma/configuration.rb b/lib/puma/configuration.rb index 5fc350fc10..69b7557b31 100644 --- a/lib/puma/configuration.rb +++ b/lib/puma/configuration.rb @@ -181,7 +181,8 @@ def default_options :tag => method(:infer_tag), :environment => lambda { ENV['RACK_ENV'] || "development" }, :rackup => DefaultRackup, - :logger => STDOUT + :logger => STDOUT, + :persistent_timeout => Const::PERSISTENT_TIMEOUT } end diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 8fa3254f24..b23752d732 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -133,6 +133,13 @@ def port(port, host=nil) bind "tcp://#{host}:#{port}" end + # Define how long persistent connections can be idle before puma closes + # them + # + def persistent_timeout(seconds) + @options[:persistent_timeout] = seconds + end + # Work around leaky apps that leave garbage in Thread locals # across requests # diff --git a/lib/puma/server.rb b/lib/puma/server.rb index a8ce73b6ef..f0d4543e9a 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -63,7 +63,7 @@ def initialize(app, events=Events.stdio, options={}) @thread = nil @thread_pool = nil - @persistent_timeout = PERSISTENT_TIMEOUT + @persistent_timeout = options[:persistent_timeout] @binder = Binder.new(events) @own_binder = true