2012-02-22 151 views
2

我使用橡膠寶石在ec2上部署我的應用程序。 我按照這裏的說明:http://ramenlab.wordpress.com/2011/06/24/deploying-your-rails-app-to-aws-ec2-using-rubber/
該過程似乎成功完成,但是當我嘗試使用該應用程序時,我一直得到504網關超時。 爲什麼會發生這種情況,我該如何解決?使用橡膠在ec2上部署後保持504網關超時

+0

你是如何使用應用程序?正確的TCP/IP端口是否打開?檢查AWS Web控制檯或命令行:) – Daan 2012-02-22 21:44:19

+0

我運行了cap deploy:check並且它沒問題,所以我認爲一切都是爲了有更好的方法來檢查? – 2012-02-23 06:37:00

+0

老實說,我從來沒有在rails上使用ruby,但是您是否查看了AWS Web控制檯中的安全設置並確認了正確的端口已打開?聽起來像是一個防火牆問題,我 – Daan 2012-02-23 18:27:01

回答

1

從馬修康威答(以下轉貼):https://groups.google.com/forum/?fromgroups#!searchin/rubber-ec2/504/rubber-ec2/AtEoOf-T9M0/zgda0Fo1qeIJ

注:即使使用這樣的代碼,你需要做的是這樣的:

>帽部署:更新

> FILTER = app01 ,app02 cap deploy:restart

> FILTER = app03,app04 cap deploy:restart


我認爲這是一個rails應用程序?軌道棧的加載速度非常慢,所以這種延遲加載時間可能就是你所看到的。乘客應該在零停機功能v3中做到這一點,但他們似乎不願意這樣做,只會在未來某個未定義的時間點將其作爲未定義付費版本的一部分提供。

我所做的是有多個應用程序服務器實例,並將它們串行重新啓動,以便我可以繼續爲其中一個服務,而其他服務器正在重新啓動。不適用於單個實例,但大多數生產設置無論如何都需要多個實例以實現冗餘/可靠性。目前這不是橡膠的一部分,但我已經爲我的應用程序部署了腳本安裝程序,並且會在某個時候合併它 - 我的配置看起來像下圖。

馬特

橡膠passenger.yml:

roles: 
    passenger: 
    rolling_restart_port: "#{passenger_listen_port}" 

    web_tools: 
    rolling_restart_port: "#{web_tools_port}" 

部署-apache.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 
+0

有趣!因此,對於「鐵軌堆疊加載速度非常緩慢」,我們通常會談論幾分鐘,幾小時......? – 2014-05-14 02:04:53

1

我得到了同樣的錯誤,並解決了這個問題。 這是「haproxy」超時。它是由Rubber安裝的負載均衡器。 設置爲30000ms,您應該在橡膠配置文件中更改它。

祝你好運!