我使用橡胶宝石在ec2上部署了我的应用程序。我遵循了这里的说明:http://ramenlab.wordpress.com/2011/06/24/deploying-your-rails-app-to-aws-ec2-using-rubber/.
这个过程似乎成功地完成了,但当我尝试使用该应用程序时,我不断得到504网关超时。为什么会发生这种情况,我该如何解决?
Matthew Conway的回答(转发如下):https://groups.google.com/forum/?fromgroups#!searchin/rubber-ec2/504/rebber-ec2/AtEoOf-T9M0/zgda0Fo1qeIJ
注意:即使使用此代码,您也需要执行以下操作:
>cap部署:更新
>FILTER=app01,app02 cap部署:重新启动
>FILTER=app03,app04 cap部署:重新启动
我想这是rails应用程序?众所周知,铁轨堆叠的装载速度很慢,所以装载时间的延迟可能就是你所看到的。Passenger本应通过零停机功能v3使其变得更好,但他们似乎违背了这一点,只会在未来某个未定义的时间点将其作为未定义的付费版本的一部分提供。
我所做的是拥有多个应用程序服务器实例,并依次重新启动它们,这样我就可以在一个实例上继续提供流量,而其他实例正在重新启动。不适用于单个实例,但大多数生产设置都需要多个实例来实现冗余/可靠性。这目前还不是橡胶的一部分,但我让它为我的应用程序部署脚本设置,并将在某个时候将其合并——我的配置如下所示。
马特
rubber-passenger.yml:
roles:
passenger:
rolling_restart_port: "#{passenger_listen_port}"
web_tools:
rolling_restart_port: "#{web_tools_port}"
deploy-pache.rb:
on :load do
rubber.serial_task self, :serial_restart, :roles => [:app, :apache] do
rsudo "service apache2 restart"
end
rubber.serial_task self, :serial_reload, :roles => [:app, :apache] do
# remove file checked by haproxy to take server out of pool, wait some
# secs for haproxy to realize it
maybe_sleep = " && sleep 5" if RUBBER_ENV == 'production'
rsudo "rm -f #{previous_release}/public/httpchk.txt #{current_release}/public/httpchk.txt#{maybe_sleep}"
rsudo "if ! ps ax | grep -v grep | grep -c apache2 &> /dev/null; then service apache2 start; else service apache2 reload; fi"
# Wait for passenger to startup before adding host back into haproxy pool
logger.info "Waiting for passenger to startup"
opts = get_host_options('rolling_restart_port') {|port| port.to_s}
rsudo "while ! curl -s -f http://localhost:$CAPISTRANO:VAR$/ &> /dev/null; do echo .; done", opts
# Touch the file so that haproxy adds this server back into the pool.
rsudo "touch #{current_path}/public/httpchk.txt#{maybe_sleep}"
end
end
after "deploy:restart", "rubber:apache:reload"
desc "Starts the apache web server"
task :start, :roles => :apache do
rsudo "service apache2 start"
opts = get_host_options('rolling_restart_port') {|port| port.to_s}
rsudo "while ! curl -s -f http://localhost:$CAPISTRANO:VAR$/ &> /dev/null; do echo .; done", opts
rsudo "touch #{current_path}/public/httpchk.txt"
end
我得到了同样的错误并解决了问题。这是"haproxy"超时。它是由Rubber安装的负载平衡器。它被设置为30000ms,您应该在橡胶配置文件中更改它。
祝你好运!