使用Unicorn实现Heroku零停机时间部署

3
我在想是否可能在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

你看过Heroku实验室中的Preboot吗?https://devcenter.heroku.com/articles/labs-preboot/ - John Beynon
我没有这样做,看起来很棒 :) - anthony
1个回答

5
更新于2014年11月14日: Preboot现在已经普遍可用(感谢@camJackson的推动)。
更改日志条目: 新的Dev Center文章:

原始回复

目前唯一的方法是使用pre-boot实验室功能:

Preboot是一个正在进行中的工作
请注意,在这种情况下,使用Unicorn没有任何影响。在这种情况下,预加载是主进程在派生工作者之前预加载Rails应用程序;这发生在新的dynos启动并循环之后。

看起来preboot现在已经正式发布了:https://devcenter.heroku.com/articles/preboot - Cam Jackson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接