Merge pull request #3859 from consul/reboot

Restart the application on every reboot
This commit is contained in:
Javier Martín
2019-11-19 22:03:31 +01:00
committed by GitHub
7 changed files with 18 additions and 14 deletions

View File

@@ -13,7 +13,7 @@ require "whenever/capistrano"
require "rvm1/capistrano3"
require "capistrano/puma"
install_plugin Capistrano::Puma
install_plugin Capistrano::Puma, load_hooks: false
#SCM: Git
require "capistrano/scm/git"

View File

@@ -45,8 +45,6 @@ set(:config_files, %w[
set :whenever_roles, -> { :app }
namespace :deploy do
Rake::Task["puma:check"].clear_actions
after :updating, "rvm1:install:rvm"
after :updating, "rvm1:install:ruby"
after :updating, "install_bundler_gem"
@@ -55,14 +53,13 @@ namespace :deploy do
after "deploy:migrate", "add_new_settings"
before :publishing, "smtp_ssl_and_delay_jobs_secrets"
after :publishing, "setup_puma"
after :publishing, "deploy:restart"
after :published, "delayed_job:restart"
after :published, "refresh_sitemap"
after :published, "deploy:restart"
before "deploy:restart", "puma:smart_restart"
before "deploy:restart", "delayed_job:restart"
before "deploy:restart", "setup_puma"
after :finishing, "deploy:cleanup"
after :finished, "refresh_sitemap"
desc "Deploys and runs the tasks needed to upgrade to a new release"
task :upgrade do

View File

@@ -1,10 +1,9 @@
#!/usr/bin/env puma
rails_root = File.expand_path("../..", __FILE__)
rails_root = File.expand_path("../../..", __FILE__)
directory rails_root
rackup "#{rails_root}/config.ru"
environment "production"
tag ""
@@ -13,12 +12,14 @@ state_path "#{rails_root}/tmp/pids/puma.state"
stdout_redirect "#{rails_root}/log/puma_access.log", "#{rails_root}/log/puma_error.log", true
bind "unix://#{rails_root}/tmp/sockets/puma.sock"
daemonize
threads 0, 16
workers 2
preload_app!
restart_command "bundle exec --keep-file-descriptors puma"
plugin :tmp_restart
on_restart do
puts "Refreshing Gemfile"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env puma
_load_from File.expand_path("../../puma.rb", __FILE__)
_load_from File.expand_path("../defaults.rb", __FILE__)
environment "preproduction"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env puma
_load_from File.expand_path("../../puma.rb", __FILE__)
_load_from File.expand_path("../defaults.rb", __FILE__)
environment "production"

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env puma
_load_from File.expand_path("../../puma.rb", __FILE__)
_load_from File.expand_path("../defaults.rb", __FILE__)
environment "staging"

View File

@@ -39,3 +39,9 @@ end
every 1.day, at: "3:00 am", roles: [:cron] do
rake "votes:reset_hot_score"
end
every :reboot do
command "cd #{@path} && bundle exec puma -C config/puma/#{@environment}.rb"
# Number of workers must be kept in sync with capistrano's delayed_job_workers
command "cd #{@path} && RAILS_ENV=#{@environment} bin/delayed_job -n 2 restart"
end