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

add RAILS_MIN_THREADS, RAILS_MAX_THREADS, set default worker, preload… #2143

Merged
merged 17 commits into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions lib/puma/detect.rb
Expand Up @@ -13,6 +13,12 @@ def self.windows?
IS_WINDOWS
end

IS_TRUFFLE = RUBY_PLATFORM == 'truffleruby'

def self.truffle?
IS_TRUFFLE
end

def self.mri?
RUBY_ENGINE == 'ruby' || RUBY_ENGINE.nil?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puma/plugin.rb
Expand Up @@ -109,7 +109,7 @@ def in_background(&blk)
end

def workers_supported?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method feels like it should be in the lib/puma/detect.rb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false if Puma.jruby? || Puma.windows?
return false if Puma.jruby? || Puma.windows? || Puma.truffle?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check ::Process.respond_to?(:fork) as well?
Does that single check eliminate the need to check for jruby/windows/truffle?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in my nitpick commit. Thanks for the work on this PR!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

true
end
end
Expand Down
3 changes: 2 additions & 1 deletion test/test_config.rb
Expand Up @@ -335,8 +335,9 @@ def test_config_does_not_preload_app_if_using_workers

def test_config_preloads_app_if_using_workers
with_env("WEB_CONCURRENCY" => "2") do
preload = Puma::Plugin.new.workers_supported?
conf = Puma::Configuration.new
assert_equal preload, conf.options.default_options[:preload_app] if ::Process.respond_to?(:fork)
assert_equal preload, conf.options.default_options[:preload_app]
end
end
end
Expand Down