Merge pull request #3859 from consul/reboot
Restart the application on every reboot
This commit is contained in:
2
Capfile
2
Capfile
@@ -13,7 +13,7 @@ require "whenever/capistrano"
|
|||||||
require "rvm1/capistrano3"
|
require "rvm1/capistrano3"
|
||||||
|
|
||||||
require "capistrano/puma"
|
require "capistrano/puma"
|
||||||
install_plugin Capistrano::Puma
|
install_plugin Capistrano::Puma, load_hooks: false
|
||||||
|
|
||||||
#SCM: Git
|
#SCM: Git
|
||||||
require "capistrano/scm/git"
|
require "capistrano/scm/git"
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ set(:config_files, %w[
|
|||||||
set :whenever_roles, -> { :app }
|
set :whenever_roles, -> { :app }
|
||||||
|
|
||||||
namespace :deploy do
|
namespace :deploy do
|
||||||
Rake::Task["puma:check"].clear_actions
|
|
||||||
|
|
||||||
after :updating, "rvm1:install:rvm"
|
after :updating, "rvm1:install:rvm"
|
||||||
after :updating, "rvm1:install:ruby"
|
after :updating, "rvm1:install:ruby"
|
||||||
after :updating, "install_bundler_gem"
|
after :updating, "install_bundler_gem"
|
||||||
@@ -55,14 +53,13 @@ namespace :deploy do
|
|||||||
after "deploy:migrate", "add_new_settings"
|
after "deploy:migrate", "add_new_settings"
|
||||||
|
|
||||||
before :publishing, "smtp_ssl_and_delay_jobs_secrets"
|
before :publishing, "smtp_ssl_and_delay_jobs_secrets"
|
||||||
|
after :publishing, "setup_puma"
|
||||||
|
|
||||||
after :publishing, "deploy:restart"
|
after :published, "deploy:restart"
|
||||||
after :published, "delayed_job:restart"
|
before "deploy:restart", "puma:smart_restart"
|
||||||
after :published, "refresh_sitemap"
|
before "deploy:restart", "delayed_job:restart"
|
||||||
|
|
||||||
before "deploy:restart", "setup_puma"
|
after :finished, "refresh_sitemap"
|
||||||
|
|
||||||
after :finishing, "deploy:cleanup"
|
|
||||||
|
|
||||||
desc "Deploys and runs the tasks needed to upgrade to a new release"
|
desc "Deploys and runs the tasks needed to upgrade to a new release"
|
||||||
task :upgrade do
|
task :upgrade do
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
#!/usr/bin/env puma
|
#!/usr/bin/env puma
|
||||||
|
|
||||||
rails_root = File.expand_path("../..", __FILE__)
|
rails_root = File.expand_path("../../..", __FILE__)
|
||||||
|
|
||||||
directory rails_root
|
directory rails_root
|
||||||
rackup "#{rails_root}/config.ru"
|
rackup "#{rails_root}/config.ru"
|
||||||
environment "production"
|
|
||||||
|
|
||||||
tag ""
|
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
|
stdout_redirect "#{rails_root}/log/puma_access.log", "#{rails_root}/log/puma_error.log", true
|
||||||
|
|
||||||
bind "unix://#{rails_root}/tmp/sockets/puma.sock"
|
bind "unix://#{rails_root}/tmp/sockets/puma.sock"
|
||||||
|
daemonize
|
||||||
|
|
||||||
threads 0, 16
|
threads 0, 16
|
||||||
workers 2
|
workers 2
|
||||||
preload_app!
|
preload_app!
|
||||||
|
|
||||||
restart_command "bundle exec --keep-file-descriptors puma"
|
restart_command "bundle exec --keep-file-descriptors puma"
|
||||||
|
plugin :tmp_restart
|
||||||
|
|
||||||
on_restart do
|
on_restart do
|
||||||
puts "Refreshing Gemfile"
|
puts "Refreshing Gemfile"
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env puma
|
#!/usr/bin/env puma
|
||||||
|
|
||||||
_load_from File.expand_path("../../puma.rb", __FILE__)
|
_load_from File.expand_path("../defaults.rb", __FILE__)
|
||||||
|
|
||||||
environment "preproduction"
|
environment "preproduction"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env puma
|
#!/usr/bin/env puma
|
||||||
|
|
||||||
_load_from File.expand_path("../../puma.rb", __FILE__)
|
_load_from File.expand_path("../defaults.rb", __FILE__)
|
||||||
|
|
||||||
environment "production"
|
environment "production"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env puma
|
#!/usr/bin/env puma
|
||||||
|
|
||||||
_load_from File.expand_path("../../puma.rb", __FILE__)
|
_load_from File.expand_path("../defaults.rb", __FILE__)
|
||||||
|
|
||||||
environment "staging"
|
environment "staging"
|
||||||
|
|||||||
@@ -39,3 +39,9 @@ end
|
|||||||
every 1.day, at: "3:00 am", roles: [:cron] do
|
every 1.day, at: "3:00 am", roles: [:cron] do
|
||||||
rake "votes:reset_hot_score"
|
rake "votes:reset_hot_score"
|
||||||
end
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user