Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow persistent_timeout to be configured via the dsl. #1017

Merged
merged 1 commit into from Jul 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/puma/configuration.rb
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions lib/puma/dsl.rb
Expand Up @@ -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
#
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/server.rb
Expand Up @@ -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
Expand Down