Mongrel cluster rolling restart,Never stop web service.
2008年2月28日星期四
本篇 Blog 介绍 Mongrel cluster 滚动重启,重启时不停止服务的方法。
更新正在运行的服务时,如果要重启 Mongrel cluster, 默认状态下 Mongrel cluster 会先 stop 然后 start, 这样网站在 stop 后会有一段时间停止服务,如果滚动重启(one-by-one)Mongrel process, 则 Nginx (或 Apache) Proxy 总会得到 upstream 的 mongrel 反馈,就不会停止服务。
这里是 rolling-restart.patch, 修改以下文件
/usr/local/lib/ruby/gems/1.8/gems/mongrel_cluster-1.0.5/lib/mongrel_cluster/init.rb
中的
class Restart < GemPlugin::Plugin “/commands”
方法如下:
class Restart < GemPlugin::Plugin “/commands”
include ExecBasedef configure
options [
[’-C’, ‘–config PATH’, “Path to cluster configuration file”,
:@config_file, “config/mongrel_cluster.yml”],
[’-f’, ‘–force’, “Force the shutdown.”, :@force, false],
[’-v’, ‘–verbose’, “Print all called commands and output.”, :@verbose, false],
['’, ‘–clean’, “Call stop and start with –clean”, :@clean, false],
['’, ‘–only PORT’, “Port number of cluster member”, :@only, nil]
]
end
def run
#stop
#start
read_options
@force, @clean = [false, true]
@ports.each do |port|
@only = port
stop
check_wait
start
end
end
private
def check_wait(wait_time = 2)
wait_time.times do
return unless check_process(@only)
sleep 1
end
log ” * Slept #{wait_time} seconds, but still not dead, force killing in 10 more.”
sleep 10
@force = true
stop
@force = false
end
end
标签: Technologies
发表评论
订阅 博文评论 [Atom]
<< 主页