Skip to content

Instantly share code, notes, and snippets.

@ParkinT
Created April 19, 2014 03:02
Show Gist options
  • Save ParkinT/11072649 to your computer and use it in GitHub Desktop.
Save ParkinT/11072649 to your computer and use it in GitHub Desktop.
Rails app will not start after Capistrano deploy on Digital Ocean Droplet. Error "504 Gateway Timeout"

Symptoms

A previously working Rails app, after a successful Capistrano deploy cycle, stops responding and the server returns the http status code 504.

Troubleshooting

I was able to successfully access the Droplet by way of SSH. Looking at the logs I noticed the unicorn server was having trouble [re]starting.

tail -f /home/unicorn/log/unicorn.log

This was the [repeating] entry in the log file

I, [2014-04-19T02:31:20.223963 #11885]  INFO -- : Refreshing Gem list                                                                                                                                          
config.ru:1:in `<main>': cannot load such file -- rack/builder (LoadError)                                                                                                                                     
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `eval'                                                                                          
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:48:in `block in builder'                                                                              
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `call'                                                                             
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:722:in `build_app!'                                                                       
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:595:in `init_worker_process'                                                              
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:615:in `worker_loop'                                                                      
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:500:in `spawn_missing_workers'                                                            
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:511:in `maintain_worker_count'                                                            
        from /usr/local/rvm/rubies/ruby-1.9.3-p429/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:277:in `join' 

Closer examimation revealed that the application had depencies expecting Rack version 1.4.2 but Rack 1.5.2 is already installed.

Fixing the problem

cd /home/rails/current, the location of the Rails application

gem uninstall rack -v 1.5.2

touch tmp/restart.txt && service nginx restart && service unicorn restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment