<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/platform.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d4684235500622716427\x26blogName\x3dCaiwangqin\x27s+blog\x26publishMode\x3dPUBLISH_MODE_HOSTED\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://blog.caiwangqin.com/search\x26blogLocale\x3dzh_CN\x26v\x3d2\x26homepageUrl\x3dhttp://blog.caiwangqin.com/\x26vt\x3d3393395200455623441', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe", messageHandlersFilter: gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER, messageHandlers: { 'blogger-ping': function() {} } }); } }); </script>

Caiwangqin's blog

Focus on Life, Cloud Service, Smart Hardware, Architecture, Technic and beyond…

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 ExecBase


def 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



标签:

posted by Caiwangqin, 10:55 | Permalink | 0 comments |

Behind P1.cn

2008年2月3日星期日

I have worked for http://p1.cn for 11 months, we used main technologies behind P1.cn below:



  1. rubyonrails, ruby

  2. mysql

  3. nginx

  4. mongrel, mongrel_cluster

  5. memcached

  6. mogilefs

  7. debian

  8. capstranio

  9. 3 people


I’m going to home for chinese new year holiday tomorrow morning at 2:14, Happy new year to everyone!


标签:

posted by Caiwangqin, 12:06 | Permalink | 0 comments |