-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set the worker process count automatically with WEB_CONCURRENCY=auto (#…
…3439) Requires the concurrent-ruby gem, displays an error message if it is not available and WEB_CONCURRENCY is set to "auto".
- Loading branch information
1 parent
5ac3f40
commit 6f26742
Showing
7 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require_relative "helper" | ||
require_relative "helpers/integration" | ||
|
||
class TestWebConcurrencyAuto < TestIntegration | ||
|
||
def teardown | ||
return if skipped? | ||
super | ||
end | ||
|
||
def test_web_concurrency_with_concurrent_ruby_available | ||
skip_unless :fork | ||
env = { | ||
"BUNDLE_GEMFILE" => "#{__dir__}/web_concurrency_test/Gemfile", | ||
"WEB_CONCURRENCY" => "auto" | ||
} | ||
Dir.chdir("#{__dir__}/web_concurrency_test") do | ||
with_unbundled_env do | ||
silent_and_checked_system_command("bundle config --local path vendor/bundle") | ||
silent_and_checked_system_command("bundle install") | ||
end | ||
cli_server set_pumactl_args, env: env | ||
end | ||
|
||
connection = connect("/worker_count") | ||
body = read_body(connection, 1) | ||
assert_equal(get_stats.fetch("workers").to_s, body) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source "https://rubygems.org" | ||
|
||
gem 'puma', path: '../..' | ||
|
||
gem 'concurrent-ruby', '~> 1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
map "/worker_count" do | ||
run ->(env) { | ||
[200, {}, [Concurrent.available_processor_count.to_i.to_s]] | ||
} | ||
end |