4

在我的 ubuntu 机器上,我可以在 ruby​​ 1.9.3 上运行 unicorn,但是,它似乎不适用于 ruby​​ 2.0。知道为什么吗?

root@dev:/home/karan# rvm use 1.9
Using /usr/local/rvm/gems/ruby-1.9.3-p429
root@dev:/home/karan# unicorn -v
unicorn v4.6.3
root@dev:/home/karan# rvm use 2.0
Using /usr/local/rvm/gems/ruby-2.0.0-p195
root@dev:/home/karan# unicorn -v
/usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- unicorn/launcher (LoadError)
        from /usr/local/rvm/rubies/ruby-2.0.0-p195/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
        from /usr/bin/unicorn:3:in `<main>'
4

2 回答 2

4

尝试使用 2.0.0 重新安装 gem。

问题一定是由于 gem 是在 1.9.3 中安装的。

于 2013-08-12T18:14:50.957 回答
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

于 2013-12-01T20:17:35.837 回答