unicorn/nginx doesn't work after changing default capistrano deployment directory

March 1, 2014 2k views
Hi Everyone, I installed a ruby on rails pre-packaged version to ubuntu 12.4. And use capistrano to deploy my app. I changed the default app directory from /home/rails to /var/www/apps/. The deployment was successful, but i got unicorn errors and the end result is timeout on the page. Please help me with this, this has confused me for quite a while, I can't really figure out why. Thanks,
5 Answers
i got unicorn errors
Can you post the errors?
this is what i see from the unicorn error log:

E, [2014-03-02T15:27:43.334218 #2773] ERROR -- : reaped # worker=1
I, [2014-03-02T15:27:43.334663 #2773] INFO -- : worker=1 spawning...
I, [2014-03-02T15:27:43.341445 #31282] INFO -- : worker=1 spawned pid=31282
I, [2014-03-02T15:27:43.347471 #31282] INFO -- : Refreshing Gem list
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/setup.rb:17:in `'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:144:in `require'
from /var/www/apps/lga/releases/20140225181502/config/boot.rb:6:in `'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/apps/lga/releases/20140225181502/config/application.rb:1:in `'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /var/www/apps/lga/releases/20140225181502/config/environment.rb:2:in `'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from config.ru:4:in `block in '
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from config.ru:1:in `new'
from config.ru:1:in `'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn.rb:48:in `block in builder'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `call'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:750:in `build_app!'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:623:in `init_worker_process'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:643:in `worker_loop'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:527:in `spawn_missing_workers'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:538:in `maintain_worker_count'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/lib/unicorn/http_server.rb:303:in `join'
from /usr/local/rvm/gems/ruby-2.0.0-p353/gems/unicorn-4.7.0/bin/unicorn:126:in `'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn:23:in `'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p353/bin/ruby_executable_hooks:15:in `'
E, [2014-03-02T15:27:43.424026 #2773] ERROR -- : reaped # worker=0
I, [2014-03-02T15:27:43.424524 #2773] INFO -- : worker=0 spawning...
I, [2014-03-02T15:27:43.427174 #31285] INFO -- : worker=0 spawned pid=31285
I, [2014-03-02T15:27:43.433696 #31285] INFO -- : Refreshing Gem list
There's your error:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup': You have already activated rack 1.5.2, but your Gemfile requires rack 1.4.5. Using bundle exec may solve this. (Gem::LoadError)

Hi,

solution for rails 3.2.x is to stop unicorn and uninstall rack 1.5.2:

service unicorn stop
gem uninstall rack -v 1.5.2

after that I have also uninstalled rack 1.5.2 dependencies:

gem uninstall actionpack-4.1.6
gem uninstall actionpack-4.0.2

, but I thing it is not necessary.

Than run bundle install and restart nginx:

service nginx restart

Finally start unicorn:

service unicorn start

It should work.
After that I had to solve some other problems, but it were small things compare to this problem.

Cheers
Kuba

Have another answer? Share your knowledge.