b05798b305
Attempt to fix some requests failing in production during a rollback, probably due to an incorrectly restarted server.
43 lines
1,020 B
Ruby
43 lines
1,020 B
Ruby
def domains_for_stage(stage)
|
|
case stage
|
|
when 'dev'
|
|
['web1.dev', 'web2.dev']
|
|
when 'prod'
|
|
['web1', 'web2', 'web3', 'web4']
|
|
else
|
|
raise "STAGE #{stage} is unknown. It must be either dev or prod."
|
|
end
|
|
end
|
|
|
|
task :setup do
|
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
|
|
|
domains.each do |domain|
|
|
sh "mina setup domain=#{domain}"
|
|
end
|
|
end
|
|
|
|
task :deploy do
|
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
|
branch = ENV.fetch('BRANCH')
|
|
|
|
domains.each do |domain|
|
|
sh "mina deploy domain=#{domain} branch=#{branch} force_asset_precompile=true"
|
|
end
|
|
end
|
|
|
|
task :post_deploy do
|
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
|
branch = ENV.fetch('BRANCH')
|
|
|
|
sh "mina post_deploy domain=#{domains.first} branch=#{branch}"
|
|
end
|
|
|
|
task :rollback do
|
|
domains = domains_for_stage(ENV.fetch('STAGE'))
|
|
branch = ENV.fetch('BRANCH')
|
|
|
|
domains.each do |domain|
|
|
sh "mina rollback service:restart_puma service:reload_nginx service:restart_delayed_job domain=#{domain} branch=#{branch}"
|
|
end
|
|
end
|