我想知道 Heroku 是否有可能实现零停机部署策略。我在当前的 Heroku 文档中发现,在推送应用程序时,重新加载应用程序大约需要 1 分钟,这使其无法使用。他们文档中的独角兽代码确实预加载了应用程序,所以我很困惑为什么会这样。有什么我可以做的吗?
https://devcenter.heroku.com/articles/rails-unicorn
我有用于弹性搜索的新遗物插件和盆景。
这是我的 unicorn.rb 初始化程序:
# config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end