简体   繁体   中英

Deploying Rails App to EC2 using Rubber: 503 Service Unavailable

So I've been working on my first (real) rails app for the last couple of weeks and yesterday I tried to deploy it to Amazon EC2 using the Rubber gem. Before I deployed my actual project I said to myself: let's try out rubber on a completely fresh and simple project just to see if it works. After executing the steps in this [railscast][1] everything worked with the simple project. So I tried to deploy my real project executing the same steps as before. Rubber executed all the Capistrano scripts and everything appeared to go well. But when I'm trying to access the website I'm getting this error: 503 Service Unavailable

I used the rubber template "complete_passenger_postgresql". The rubber settings between the simple project that I successfully deployed and the real project are basically the same. The difference is in the actual content of the app.

After reviewing the log files I came accross those errors:

Apache Error Log:

    [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 LOG:

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 Production Log

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')

Could it be that the gem "Ancestry" might be causing this problem? And what about the "Permission Denied" errors?

Thanks so much for your help!

I managed to solve the above mentioned problems the following way:

First I gave the rails project's directories & files proper rights by applying

sudo chmod -R 777 ProjectDirectory

This solved the Apache permission error. The reason why this problem occured was the fact that I created the project on another windows and linux machine and tried to deploy it on a mac. The simple test project worked because I created it on the same machine on which I deployed it.

Next I added the following line of code into my see.rb file to get rid of the "uninitialized constant ActiveRecord" error:

require 'active_record'

After those adjustments I deployed everything once again using rubber and it's working :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM