Speed up deployment when Ruby is already installed

We were installing RVM every time we were deploying, which meant
deployments took a few extra seconds and generated a lot of unneeded
output even when we didn't have to update Ruby.

We need to update RVM when a new Ruby version needs to be installed
(otherwise we could be asking RVM to install a Ruby version which the
current RVM version cannot handle), but in every other case we're fine
using the already installed RVM version.

We're also considering the case where the RVM command is not available.
Even though the CONSUL installer installs RVM, some people might prefer
to install it through Capistrano.
This commit is contained in:
Javi Martín
2020-10-31 13:16:21 +01:00
parent 6a3dd0504b
commit e042491169

View File

@@ -39,8 +39,7 @@ namespace :deploy do
Rake::Task["delayed_job:default"].clear_actions
Rake::Task["puma:smart_restart"].clear_actions
after :updating, "rvm1:install:rvm"
after :updating, "rvm1:install:ruby"
after :updating, "install_ruby"
after "deploy:migrate", "add_new_settings"
@@ -60,6 +59,26 @@ namespace :deploy do
end
end
task :install_ruby do
on roles(:app) do
within release_path do
begin
current_ruby = capture(:rvm, "current")
rescue SSHKit::Command::Failed
after "install_ruby", "rvm1:install:rvm"
after "install_ruby", "rvm1:install:ruby"
else
if current_ruby.include?("not installed")
after "install_ruby", "rvm1:install:rvm"
after "install_ruby", "rvm1:install:ruby"
else
info "Ruby: Using #{current_ruby}"
end
end
end
end
end
task :refresh_sitemap do
on roles(:app) do
within release_path do