0

因此,我在過去幾週一直在研究我的第一個(真正的)rails應用程序,昨天我試圖使用Rubber gem將它部署到Amazon EC2。在我部署我的實際項目之前,我對自己說:讓我們嘗試一個完全新鮮和簡單的項目上的橡膠,看看它是否工作。在執行這個[railscast] [1]中的步驟之後,所有的東西都可以在簡單的項目中使用。所以我試圖部署我的真實項目,執行與以前相同的步驟。橡皮執行了所有Capistrano腳本,一切看起來都很順利。但是,當我試圖訪問該網站時,出現此錯誤:503服務不可用使用橡膠部署Rails應用程序到EC2:503服務不可用

我使用了橡膠模板「complete_passenger_postgresql」。我成功部署的簡單項目與實際項目之間的橡膠設置基本相同。區別在於應用程序的實際內容。

查看日誌文件後,我就翻過這些錯誤:

Apache的錯誤日誌:

[Thu Dec 13 14:24:02 2012] [notice] Apache/2.2.22 (Ubuntu) configured -- resuming normal operations 
[Thu Dec 13 14:24:10 2012] [notice] Graceful restart requested, doing restart 
[Thu Dec 13 14:24:10 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 configured -- resuming normal operations 
[Thu Dec 13 14:24:10 2012] [notice] caught SIGTERM, shutting down 
[Thu Dec 13 14:24:12 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+. 
[Thu Dec 13 14:24:12 2012] [warn] mod_wsgi: Runtime using Python/2.7.3. 
[Thu Dec 13 14:24:12 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations 
[Thu Dec 13 14:24:51 2012] [notice] caught SIGTERM, shutting down 
[Thu Dec 13 14:26:26 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+. 
[Thu Dec 13 14:26:26 2012] [warn] mod_wsgi: Runtime using Python/2.7.3. 
[Thu Dec 13 14:26:26 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations 
[Thu Dec 13 14:50:55 2012] [notice] caught SIGTERM, shutting down 
[Thu Dec 13 14:51:50 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+. 
[Thu Dec 13 14:51:50 2012] [warn] mod_wsgi: Runtime using Python/2.7.3. 
[Thu Dec 13 14:51:51 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_wsgi/3.3 Python/2.7.3 configured -- resuming normal operations 
[Thu Dec 13 14:54:49 2012] [notice] caught SIGTERM, shutting down 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] RSA server certificate CommonName (CN) `production.test.com' does NOT match server name!? 
[Thu Dec 13 14:57:48 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366) 
[Thu Dec 13 14:57:48 2012] [warn] mod_wsgi: Compiled for Python/2.7.2+. 
[Thu Dec 13 14:57:48 2012] [warn] mod_wsgi: Runtime using Python/2.7.3. 
[Thu Dec 13 14:57:48 2012] [notice] Apache/2.2.22 (Ubuntu) proxy_html/3.0.1 mod_ssl/2.2.22 OpenSSL/1.0.1 mod_wsgi/3.3 Python/2.7.3 Phusion_Passenger/3.0.17 configured -- resuming normal operations 
[Thu Dec 13 14:57:53 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable 
[Thu Dec 13 14:57:55 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable 
[Thu Dec 13 14:57:57 2012] [crit] [client XX.XXX.XXX.XX] (13)Permission denied: /mnt/test_core-production/releases/20121213133228/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable 
Last Line repeats like a 1000 times. 

的Cron-SH-綁定日誌:

rubber:cron running ["bundle", "exec", "rake", "subscriptions:send"] at 2012-12-13 20:15:06 +0100 
rake aborted! 
uninitialized constant ActiveRecord 
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry/has_ancestry.rb:1:in `<top (required)>' 
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry.rb:4:in `require' 
/mnt/test_core-production/shared/bundle/ruby/1.9.1/gems/ancestry-1.3.0/lib/ancestry.rb:4:in `<top (required)>' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require' 
/usr/local/rvm/gems/[email protected]/gems/bundler-1.2.3/lib/bundler.rb:128:in `require' 
/usr/local/graylog2-web-interface-0.9.6p1/config/application.rb:16:in `<top (required)>' 
/usr/local/graylog2-web-interface-0.9.6p1/Rakefile:4:in `require' 
/usr/local/graylog2-web-interface-0.9.6p1/Rakefile:4:in `<top (required)>' 
(See full trace by running task with --trace) 

Rails的生產測井

Connecting to database specified by database.yml 
Compiled jquery.js (2ms) (pid 23834) 
Compiled jquery-ui.js (7ms) (pid 23834) 
... 
Connecting to database specified by database.yml 
Migrating to CreateUsers (20120903114829) 
... 
Connecting to database specified by database.yml 
Connecting to database specified by database.yml 
PG::Error: connection not open // <-- I think this happens while seeding data 
: UPDATE "delayed_jobs" SET locked_by = null, locked_at = null WHERE (locked_by = 'delayed_job host:production.test.com pid:24702') 

Cou這是寶石「祖先」可能導致這個問題嗎?那麼「權限被拒絕」錯誤呢?

非常感謝您的幫助!

+0

在您的Apache,Passenger和應用程序日誌中添加可能會讓我們更好地瞭解爲何發生這種情況。 – Veraticus

+0

感謝Veraticus - 我只是更新了這篇文章。任何其他可能感興趣的日誌文件?我讀到Passenger錯誤日誌正被重定向到apaches錯誤日誌文件。 –

回答

0

我設法解決上述問題的方式如下:

首先,我給了Rails項目的目錄&通過應用

sudo chmod -R 777 ProjectDirectory 

這解決了Apache許可錯誤文件的正當權利。發生此問題的原因是,我在另一臺Windows和Linux計算機上創建了該項目,並試圖將其部署到Mac上。簡單的測試項目工作,因爲我在我部署它的同一臺機器上創建它。

接下來,我添加的代碼下面一行到我see.rb文件,以擺脫「未初始化不斷ActiveRecord的」錯誤:

require 'active_record' 

我的一切部署這些調整後再次使用的橡膠,它的工作:-)

+0

嘿,你在服務器上還是本地運行'sudo chmod -R 777 ProjectDirectory'?如果在服務器上,abouts是項目目錄?當我以ubuntu登錄並運行'ls'時,我看不到任何文件或目錄。 – wkdshot

+1

我在本地運行它,然後執行橡膠部署過程。但是我可以告訴你服務器上的確切路徑,如果你可以等待幾天(得到煙道但星期三應該在辦公室)。 –

+0

謝謝,我昨天發現它。對於任何在amazon EC2上以'ubuntu'登錄的人,它是:'cd ../../ mnt/ProjectName-environment'。再次感謝! – wkdshot

相關問題