From dffc5c1240ecafb8e5e15fa38ccb4db859f3c5f1 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Thu, 3 Mar 2022 17:19:42 +0100 Subject: [PATCH] Updates puma to 5.6.2 (was 4.3.11) Also use pumactl to "hot" restart --- Gemfile | 2 +- Gemfile.lock | 4 ++-- config/deploy.rb | 5 ++--- config/puma.rb | 20 +++++++------------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index 47686a64..fd5fa7e6 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ else end # Use Puma as the app server -gem 'puma', '~> 4.3' +gem 'puma' # respond_to methods have been extracted to the responders gem # http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#responders diff --git a/Gemfile.lock b/Gemfile.lock index 4e496c83..29eb5cd8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -415,7 +415,7 @@ GEM prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) public_suffix (4.0.6) - puma (4.3.11) + puma (5.6.2) nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) @@ -695,7 +695,7 @@ DEPENDENCIES pg prawn-qrcode prawn-rails - puma (~> 4.3) + puma rails (~> 7.0) rails-assets-bootstrap-markdown! rails-assets-bootstrap-select! diff --git a/config/deploy.rb b/config/deploy.rb index eac6bf00..cb0d9489 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -19,7 +19,7 @@ set :branch, OSEM_DEPLOY_BRANCH # Shared dirs and files will be symlinked into the app-folder by the 'deploy:link_shared_paths' step. # Some plugins already add folders to shared_dirs like `mina/rails` add `public/assets`, `vendor/bundle` and many more # run `mina -d` to see all folders and files already included in `shared_dirs` and `shared_files` -set :shared_dirs, fetch(:shared_dirs, []).push('public/system', '.bundle') +set :shared_dirs, fetch(:shared_dirs, []).push('public/system', '.bundle', 'tmp/pids') set :shared_files, fetch(:shared_files, []).push('.env.production') desc "Deploys the current version to the server." @@ -36,8 +36,7 @@ task :deploy do on :launch do in_path(fetch(:current_path)) do - command %{mkdir -p tmp/} - command %{touch tmp/restart.txt} + command %{bundle exec pumactl restart -e production} command %{sudo systemctl restart osem-dj} end end diff --git a/config/puma.rb b/config/puma.rb index c867218c..208cea5d 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,33 +4,27 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" +threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 } +threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch('PORT') { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch("RAILS_ENV") { "development" } +environment ENV.fetch('RAILS_ENV') { 'development' } # Specifies the `pidfile` that Puma will use. pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } # Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together +# Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # -workers ENV.fetch("WEB_CONCURRENCY") { 2 } +workers ENV.fetch('WEB_CONCURRENCY') { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code @@ -40,4 +34,4 @@ workers ENV.fetch("WEB_CONCURRENCY") { 2 } preload_app! # Allow puma to be restarted by `rails restart` command. -plugin :tmp_restart +plugin 'tmp_restart'