How to use unicorn server on Rails 3

18 views
Skip to first unread message

Colin Law

unread,
Dec 8, 2010, 4:25:16 PM12/8/10
to rubyonra...@googlegroups.com
I am using Rails 3.0.3, Ruby 1.9.2 with rvm on Ubunutu 10.04. I
generated a new app by rails new testunicorn. By default the Webrick
server runs ok. In order to try Unicorn I uncommented gem 'unicorn'
in Gemfile and did bundle install. rails server still runs webrick
and doing rails server unicorn leads to

colinl@piglet:~/websites/testunicorn$ rails s unicorn
Exiting
/home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/handler.rb:21:in
`const_get': wrong constant name unicorn (NameError)
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/handler.rb:21:in
`get'
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/server.rb:217:in
`server'
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/server.rb:54:in
`start'
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:30:in
`block in <top (required)>'
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:27:in
`tap'
from /home/colinl/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:27:in
`<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

Do I need to do something else to use unicorn? Google has not
suggested anything. There was one hit with the same problem in (I
think) Indonesian and google did not seem able to translate it.

Help would be much appreciated.

Colin

Gemfile.lock contains
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.6)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
kgio (2.0.0)
mail (2.2.11)
activesupport (>= 2.3.6)
i18n (~> 0.5.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
sqlite3-ruby (1.3.2)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
unicorn (3.0.1)
kgio (~> 2.0.0)
rack

PLATFORMS
ruby

DEPENDENCIES
rails (= 3.0.3)
sqlite3-ruby
unicorn

Hassan Schroeder

unread,
Dec 8, 2010, 4:47:40 PM12/8/10
to rubyonra...@googlegroups.com
On Wed, Dec 8, 2010 at 1:25 PM, Colin Law <cla...@googlemail.com> wrote:
> I am using Rails 3.0.3, Ruby 1.9.2 with rvm on Ubunutu 10.04.  I
> generated a new app by rails new testunicorn.  By default the Webrick
> server runs ok.  In order to try Unicorn I uncommented gem 'unicorn'
> in Gemfile and did bundle install.  rails server still runs webrick
> and doing rails server unicorn leads to
>
> colinl@piglet:~/websites/testunicorn$ rails s unicorn

Works for me just starting it as `unicorn_rails` like in 2.3.x ...

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan

Colin Law

unread,
Dec 9, 2010, 3:59:25 AM12/9/10
to rubyonra...@googlegroups.com
On 8 December 2010 21:47, Hassan Schroeder <hassan.s...@gmail.com> wrote:
> On Wed, Dec 8, 2010 at 1:25 PM, Colin Law <cla...@googlemail.com> wrote:
>> I am using Rails 3.0.3, Ruby 1.9.2 with rvm on Ubunutu 10.04.  I
>> generated a new app by rails new testunicorn.  By default the Webrick
>> server runs ok.  In order to try Unicorn I uncommented gem 'unicorn'
>> in Gemfile and did bundle install.  rails server still runs webrick
>> and doing rails server unicorn leads to
>>
>> colinl@piglet:~/websites/testunicorn$ rails s unicorn
>
> Works for me just starting it as `unicorn_rails` like in 2.3.x ...

The docs suggest unicorn_rails is not required for Rails 3.

Colin

Julien Palmas

unread,
Mar 10, 2011, 4:58:54 AM3/10/11
to rubyonra...@googlegroups.com
`unicorn_rails` n'est en effet pas recommandé pour les apps rails 3

http://unicorn.bogomips.org/unicorn_rails_1.html
<quote>
It is designed to help Rails 1.x and 2.y users transition to
Rack, but
it is NOT needed for Rails 3 applications. Rails 3 users are encouraged
to use unicorn(1) instead of unicorn_rails(1). Users of Rails 1.x/2.y
may also use unicorn(1) instead of unicorn_rails(1).
</quote>

Instead, you can start your rails3 server with `unicorn`
http://unicorn.bogomips.org/unicorn_1.html

In the mean time, it'd be great if one could start unicorn with `rails s
unicorn`, but as Colin said, it does not work.

This is because Rack misses a "Handler" for Unicorn.
It already has one for Webrick, Thin, Mongrel and others, but not for
Unicorn

I could not find the handler with google and will try the Unicorn ML to
ask

Julien

--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages