From b36e659f4eedbc9109d04fffccf5b4f746bd53e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 10 Oct 2019 22:08:55 +0200 Subject: [PATCH] Use puma instead of unicorn Puma is the server we use in the development environment, so this way we don't need to maintain two servers. Furthermore, puma seems to offer a few advantages over unicorn (like multithreading) and no disadvantages. --- Capfile | 3 +++ Gemfile | 4 ++-- Gemfile.lock | 15 +++++++-------- config/deploy.rb | 3 +-- lib/capistrano/tasks/restart.cap | 11 ----------- 5 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 lib/capistrano/tasks/restart.cap diff --git a/Capfile b/Capfile index cef760291..335828c06 100644 --- a/Capfile +++ b/Capfile @@ -12,6 +12,9 @@ require "capistrano/delayed_job" require "whenever/capistrano" require "rvm1/capistrano3" +require "capistrano/puma" +install_plugin Capistrano::Puma + #SCM: Git require "capistrano/scm/git" install_plugin Capistrano::SCM::Git diff --git a/Gemfile b/Gemfile index 5ad8bccfe..b13cc75a2 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,7 @@ gem "paperclip", "~> 5.2.1" gem "paranoia", "~> 2.4.2" gem "pg", "~> 0.21.0" gem "pg_search", "~> 2.0.1" +gem "puma", "~> 4.2.1" gem "recipient_interceptor", "~> 0.2.0" gem "redcarpet", "~> 3.4.0" gem "responders", "~> 2.4.0" @@ -55,7 +56,6 @@ gem "translator-text", "~> 0.1.0" gem "turbolinks", "~> 2.5.3" gem "turnout", "~> 2.4.0" gem "uglifier", "~> 4.1.2" -gem "unicorn", "~> 5.4.1" gem "whenever", "~> 0.10.0", require: false gem "wicked_pdf", "~> 1.1.0" gem "wkhtmltopdf-binary", "~> 0.12.4" @@ -74,7 +74,6 @@ group :development, :test do gem "knapsack_pro", "~> 1.1.0" gem "launchy", "~> 2.4.3" gem "letter_opener_web", "~> 1.3.4" - gem "puma", "~> 4.1.1" gem "spring", "~> 2.0.1" gem "spring-commands-rspec", "~> 1.0.4" end @@ -94,6 +93,7 @@ group :development do gem "capistrano-bundler", "~> 1.2", require: false gem "capistrano-rails", "~> 1.4.0", require: false gem "capistrano3-delayed-job", "~> 1.7.3" + gem "capistrano3-puma", "~> 4.0.0" gem "erb_lint", require: false gem "mdl", "~> 0.5.0", require: false gem "rubocop", "~> 0.75.0", require: false diff --git a/Gemfile.lock b/Gemfile.lock index aa490cd70..dcb108500 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,6 +116,10 @@ GEM capistrano3-delayed-job (1.7.5) capistrano (~> 3.0, >= 3.0.0) daemons (~> 1.2.4) + capistrano3-puma (4.0.0) + capistrano (~> 3.7) + capistrano-bundler + puma (~> 4.0) capybara (2.17.0) addressable mini_mime (>= 0.1.3) @@ -301,7 +305,6 @@ GEM activerecord kaminari-core (= 1.1.1) kaminari-core (1.1.1) - kgio (2.11.2) knapsack_pro (1.1.0) rake kramdown (1.17.0) @@ -388,7 +391,7 @@ GEM activesupport (>= 4.2) arel (>= 6) public_suffix (4.0.1) - puma (4.1.1) + puma (4.2.1) nio4r (~> 2.0) rack (2.0.7) rack-accept (0.4.5) @@ -428,7 +431,6 @@ GEM rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (3.0.0) - raindrops (0.19.0) rake (12.3.3) recipient_interceptor (0.2.0) mail @@ -554,9 +556,6 @@ GEM uglifier (4.1.19) execjs (>= 0.3.0, < 3) unicode-display_width (1.6.0) - unicorn (5.4.1) - kgio (~> 2.6) - raindrops (~> 0.7) uniform_notifier (1.11.0) user_agent_parser (2.4.1) uuidtools (2.1.5) @@ -598,6 +597,7 @@ DEPENDENCIES capistrano-bundler (~> 1.2) capistrano-rails (~> 1.4.0) capistrano3-delayed-job (~> 1.7.3) + capistrano3-puma (~> 4.0.0) capybara (~> 2.17.0) capybara-webmock (~> 0.5.3) ckeditor (~> 4.2.3) @@ -641,7 +641,7 @@ DEPENDENCIES paranoia (~> 2.4.2) pg (~> 0.21.0) pg_search (~> 2.0.1) - puma (~> 4.1.1) + puma (~> 4.2.1) rails (= 5.0.7.2) rails-assets-leaflet! rails-assets-markdown-it (~> 8.2.1)! @@ -669,7 +669,6 @@ DEPENDENCIES turbolinks (~> 2.5.3) turnout (~> 2.4.0) uglifier (~> 4.1.2) - unicorn (~> 5.4.1) web-console (~> 3.3.0) whenever (~> 0.10.0) wicked_pdf (~> 1.1.0) diff --git a/config/deploy.rb b/config/deploy.rb index c56d88f3e..417336372 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -21,7 +21,7 @@ set :log_level, :info set :pty, true set :use_sudo, false -set :linked_files, %w[config/database.yml config/secrets.yml config/unicorn.rb config/environments/production.rb] +set :linked_files, %w[config/database.yml config/secrets.yml config/environments/production.rb] set :linked_dirs, %w[log tmp public/system public/assets public/ckeditor_assets] set :keep_releases, 5 @@ -35,7 +35,6 @@ set(:config_files, %w[ log_rotation database.yml secrets.yml - unicorn.rb ]) set :whenever_roles, -> { :app } diff --git a/lib/capistrano/tasks/restart.cap b/lib/capistrano/tasks/restart.cap deleted file mode 100644 index e8975077e..000000000 --- a/lib/capistrano/tasks/restart.cap +++ /dev/null @@ -1,11 +0,0 @@ -namespace :deploy do - desc "Restart Unicorn" - task :restart do - on roles(:app) do - execute "kill -QUIT `cat #{deploy_to}/pids/unicorn.pid`; true" - execute "kill -QUIT `cat #{shared_path}/pids/unicorn.pid`; true" - execute "kill -QUIT `cat #{shared_path}/tmp/pids/unicorn.pid`; true" - execute "cd #{release_path} && bundle exec unicorn -c config/unicorn.rb -E production -D" - end - end -end