使用Rubber将Rails应用程序部署到EC2:503服务不可用

时间:2012-12-13 16:34:22

标签: ruby-on-rails ruby-on-rails-3 deployment amazon-ec2 passenger

所以我在过去几周一直在研究我的第一个(真正的)rails应用程序,昨天我尝试使用Rubber gem将其部署到Amazon EC2。在我部署我的实际项目之前,我对自己说:让我们在一个完全新鲜而简单的项目上尝试橡胶,看它是否有效。在执行了这个[railcast] [1]中的步骤后,一切都与简单项目一起工作。所以我尝试部署我的实际项目,执行与以前相同的步骤。橡胶执行所有Capistrano脚本,一切似乎进展顺利。但是,当我尝试访问该网站时,我收到此错误: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-Bundle日志:

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/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/gems/bundler-1.2.3/lib/bundler/runtime.rb:55:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327@global/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')

宝石“祖先”可能会导致这个问题吗?那么“Permission Denied”错误呢?

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

我设法通过以下方式解决了上述问题:

首先我给了rails项目的目录&amp;通过申请

来申请适当的权利
sudo chmod -R 777 ProjectDirectory

这解决了Apache权限错误。之所以出现这个问题,是因为我在另一台Windows和Linux机器上创建了该项目,并尝试将其部署在mac上。简单的测试项目有效,因为我在部署它的同一台机器上创建了它。

接下来,我将以下代码行添加到我的see.rb文件中,以摆脱“未初始化的常量ActiveRecord”错误:

require 'active_record'

经过这些调整之后,我再次使用橡胶部署了一切,并且它正在工作: - )