【问题标题】:Deploying Rails App to EC2 using Rubber: 503 Service Unavailable使用 Rubber 将 Rails 应用程序部署到 EC2:503 服务不可用
【发布时间】:2012-12-01 14:32:48
【问题描述】:

所以过去几周我一直在开发我的第一个(真正的)rails 应用程序,昨天我尝试使用 Rubber gem 将它部署到 Amazon EC2。在我部署我的实际项目之前,我对自己说:让我们在一个全新且简单的项目上尝试一下橡胶,看看它是否有效。在执行了这个 [railscast][1] 中的步骤之后,一切都与这个简单的项目一起工作了。所以我尝试部署我的真实项目,执行与以前相同的步骤。 Rubber 执行了所有 Capistrano 脚本,一切似乎都很顺利。但是当我尝试访问该网站时,我收到了这个错误:503 Service Unavailable

我使用了橡胶模板“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”错误呢?

非常感谢您的帮助!

【问题讨论】:

  • 添加您的 Apache、Passenger 和应用程序日志可能会让我们更好地了解为什么会发生这种情况。
  • 谢谢 Veraticus - 我刚刚更新了帖子。任何其他可能感兴趣的日志文件?我读到乘客错误日志正在被重定向到 apaches 错误日志文件。

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


【解决方案1】:

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

首先,我通过应用为 rails 项目的目录和文件赋予了适当的权限

sudo chmod -R 777 ProjectDirectory

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

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

require 'active_record'

在这些调整之后,我再次使用橡胶部署了所有东西,它正在工作:-)

【讨论】:

  • 嘿,你是在服务器上还是在本地运行sudo chmod -R 777 ProjectDirectory?如果在服务器上,项目目录在哪里?当我以 ubuntu 身份登录并运行 ls 时,我看不到任何文件或目录。
  • 我在本地运行它,然后我执行了橡胶部署过程。但是我也可以告诉你服务器上的确切路径,如果你可以等待几天(得到了烟道,但应该周三在办公室)。
  • 谢谢,我昨天找到了。对于在亚马逊 EC2 上以 ubuntu 登录的任何人,它是:cd ../../mnt/ProjectName-environment。再次感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-15
  • 1970-01-01
  • 1970-01-01
  • 2011-06-28
  • 2013-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多