なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2024/08/08)

2024/08/08分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

actionpack/CHANGELOG.md


Let allow_browser allow bots

actionpack/lib/action_controller/metal/allow_browser.rbの修正です。

allow_browser APIで、botからのアクセスの場合、指定されたブラウザのバージョンよりバージョンが古くてもアクセス出来るよう修正しています。search engineによるクローリングをブロックしないようにするため。


Make auto detection of CPUs in default puma config optional, not default

railties/lib/rails/generators/rails/app/templates/config/deploy.yml.ttrailties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

Pumaのworker数のデフォルト値にConcurrent.available_processor_countを使用していたのを、WEB_CONCURRENCY envにautoという文字列が使われた場合のみConcurrent.available_processor_countを使用し、そうでない場合はWEB_CONCURRENCY envの値(指定が無い場合は1)を使用するよう修正しています。幾つかのホスティング環境ではConcurrent.available_processor_countでも正しい使用可能なコア数が取得出来ないことがあり、そのような環境で予期せぬエラーになってしまうのを避けるため。

が、WEB_CONCURRENCY envにautoを指定することは出来なかったため、後ほど削除されています。


Comment out Kamal WEB_CONCURRENCY config, since it already defaults to 1

railties/lib/rails/generators/rails/app/templates/config/deploy.yml.ttの修正です。

Kamalのconfig内のWEB_CONCURRENCYの指定をコメントアウトするよう修正しています。1が指定されていたのですが、これはデフォルトの値と一致し、明示的に指定する必要が無いため。変わりにデフォルトと違う値(2)を指定するよう修正しています。


Merge pull request #52379 from dixpac/dix/normalize_auth_email

railties/lib/rails/generators/rails/authentication/templates/models/user.rbの修正です。

session generatorが生成するmodel用のテンプレートファイルで、email addressを保存前にすべて小文字に変換するよう修正しています。大文字小文字が混在してしまうのを避けるため。


Puma defines thread(min, max = min) so no reason to pass min twice

railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

Pumaのスレッド数を指定する際に、maxとminが同じ値の場合に不要な2つめの引数を削除するよう修正しています。

が、リリースされているPumaではまだ削除出来なかったため、後ほどRevertされています。


Missing comment mark

railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

コメントのフォーマットを修正しています。


Now that we are only setting it once we can set it directly railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

Pumaのスレッド数を指定する際に、RAILS_MAX_THREADS envの値を一度変数に代入してから指定していたのを、直接メソッドに指定するよう修正しています。

Puma defines thread(min, max = min) so no reason to pass min twice の対応に関連して行われた修正だったのですが、そもそもの対応がまだリリース済みのPumaでは問題があったため、こちらの修正も後ほどRevertされています。


Document the fact that Puma 5.0+ now pulls from WEB_CONCURRENCY directly

railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

Pumaのworker数をenv(WEB_CONCURRENCY)で指定する方法についての説明コメントを追加しています。


Puma 5+ now pulls WEB_CONCURRENCY directly from ENV, so we cannot/should not override

Pumaのworker数をenv(WEB_CONCURRENCY)から取得した値で明示的に指定していたのを削除しています。Puma本体でWEB_CONCURRENCY envからworker数を設定する対応が行われており、アプリ側で行う必要が無い為。なお、autoという文字列を指定しての挙動の制御は無いため、そちらは単純に削除されています。


Revert "Now that we are only setting it once we can set it directly"

Pumaのスレッド数を指定する際にRAILS_MAX_THREADS envの値を一度変数に代入してから指定していたのを直接メソッドに指定するよう修正した、Now that we are only setting it once we can set it directly をRevertしています。


This feature has not yet been released, it's only on puma/main

railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

Pumaのスレッド数を指定する際に、maxとminが同じ値の場合に不要な2つめの引数を削除したのを、再度maxとminそれぞれに値を指定するよう修正しています。maxとminが同じ値の挙動はリリースされているgemでは使用出来ないため。


This feature needs to exist in puma

railties/lib/rails/generators/rails/app/templates/config/deploy.yml.ttの修正です。

Puma 5+ now pulls WEB_CONCURRENCY directly from ENV, so we cannot/should not overrideで削除された、WEB_CONCURRENCY envにautoという文字列を指定した場合の挙動を削除しています。


Remove redundant Puma configuration settings from fresh config/puma.rb files

railties/lib/rails/generators/rails/app/templates/config/puma.rb.ttの修正です。

environmentの設定やpreload_app!の呼び出しなど、Puma側で自動で行ってくれる挙動を設定ファイルから削除しています。


Fix comments for ease of comment/uncomment like builder block

railties/lib/rails/generators/rails/app/templates/config/deploy.yml.ttの修正です。

コメントアウトの追加/削除をしやすくするようにするため、#を行の先頭で指定するよう修正しています。


Make route mapping scope lookups faster

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

route mappingのscope取得処理について、処理高速化のためのリファクタリングを行っています。


Remove a duplicated line

actionpack/lib/action_dispatch/routing/mapper.rbのdocの修正です。

matchメソッドのdoc内のexampleコードにまったく同じ内容をコードが2行あったのを、片方削除しています。


Document THOR_MERGE and THOR_DIFF vars during upgrade

rails guideのUpgrading Ruby on Railsの修正です。

The Update Taskセクションに、THOR_DIFF及びTHOR_MERGE envに、app:update実行中に使用出来るdiff及びmergeツールを指定出来る旨説明を追加しています。


Remove WEB_CONCURRENCY "auto" from tuning_performance_for_deployment (#52545)

rails guideのTuning Performance for Deploymentの修正です。

Puma 5+ now pulls WEB_CONCURRENCY directly from ENV, so we cannot/should not overrideで削除された、WEB_CONCURRENCY envにautoという文字列を指定した場合の挙動の説明を削除しています。