如何使用 Unicorn 进行滚动重启? [英] How to do rolling restart with Unicorn?

查看:53
本文介绍了如何使用 Unicorn 进行滚动重启?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我对我的 rails 应用程序进行了一些更改,例如更改 html 布局.我将如何使用 Unicorn 进行滚动重启?实际上,人们希望为最新版本的 rails 应用程序引入独角兽进程(或工作人员?),然后以原子方式将流量从旧的独角兽进程/工作人员切换到新的进程.从 Google 搜索中,我无法对如何做到这一点以及围绕它的所有问题给出具体明确的解释.

Suppose I make a little change to my rails app such as changing the html layout. How would I do a rolling restart with Unicorn? Effectively one would like to bring up unicorn processes(or workers instead?) for the newest version of the rails app and then switch traffic from the old unicorn processes/workers to the new ones atomically. From Google searches I couldn't quite get a concrete definitive explanation of how to do this and all the gotchas surrounding it.

推荐答案

有多种方法,其中一种如下:

There are multiple methods, but one of them is as follows:

  • 将 SIGUSR2 发送到主进程.Unicorn 启动一个带有工作进程的新主进程,这些进程与您的旧主进程和旧工作进程并行运行.
  • 等待新的主进程和工作进程启动.
  • 杀死老主人.

来源:http://unicorn.bogomips.org/SIGNALS.html

虽然这对内存不是很友好.您暂时需要两倍的内存使用量.

This is not very memory friendly though. You temporarily need twice the memory usage.

Phusion Passenger Enterprise 支持滚动重启(以及其他很酷的功能),但它会逐个重启进程-one 等不需要那么多内存.可以使用 TTIN 和 TTOUT 信号在 Unicorn 中编写一对一滚动重启的脚本,但 Phusion Passenger 会自动为您完成所有操作,无需编写脚本.

Phusion Passenger Enterprise supports rolling restarts (along with other cool features) but it restarts processes one-by-one and so does not need as much memory. It is possible to script one-by-one rolling restarts in Unicorn using the TTIN and TTOUT signals but Phusion Passenger does everything automatically for you without scripting.

这篇关于如何使用 Unicorn 进行滚动重启?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆