Cannot run Unicorn with Ruby 2.0

旧城冷巷雨未停 提交于 2019-12-05 13:13:06

Try reinstalling the gem with 2.0.0.

The problem must have been caused by the fact the gem was installed in 1.9.3.

I have the exact same problem when I try to start Unicorn server

Starting Unicorn web server unicorn
/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': cannot load such file -- unicorn/launcher (LoadError)
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/bin/unicorn:3:in `<main>'

Nevertheless, Unicorn works fine when I run it from the rails app folder, simply using "unicorn" command.

I have tried what you suggest, installing the gem unicorn

gem install 'unicorn'

But it does not change the result

I check what gem is installed:

which gem 'unicorn'
/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/gem
/usr/local/rvm/gems/ruby-2.0.0-p353/bin/unicorn

I am running unicorn from a etc/init.d script that you can see here:

http://pastebin.com/qvwdmRJ2

and here for the default configuration:

http://pastebin.com/84FBQjMp

There seems to be some problem with the PATH of the default configuration file:

PATH=/usr/local/rvm/rubies/ruby-2.0.0-p353/bin:/home/unicorn/.rvm/bin:/usr/local/sbin:/usr/bin:/bin:/sbin:$

Because since I updated it with the new installed version I get the error message shown at the top. If I remove it, Unicorn "apparently starts" but the log shows a crazy activity and nginx shows an empty screen.

I am trying to find a solution and will share it here as soon as I find it.

Thanks for your help

* UPDATE *

OK I have found the problems:

1) for the /etc/init.d script:

You need to create a wrapper for Unicorn to work in a init.d type of script:

rvm wrapper 2.0.0 ruby-2.0.0 unicorn

then replace the line

DAEMON=/usr/bin/unicorn

with this one:

DAEMON=/usr/local/rvm/bin/ruby-2.0.0_unicorn

And now the command

service unicorn start

more on rvm wrapper here: https://rvm.io/integration/init-d

2) I also had another issue that was difficult to identify in the log:

I had not created a config/environments/staging.rb file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!