Sysadmin Setup question for Unicorn

Chris Wanstrath chris at ozmm.org
Tue Nov 3 12:13:13 EST 2009


On Tue, Nov 3, 2009 at 4:19 AM, huet bartels <hbartels at i-neda.com> wrote:

> I am trying to setup unicorn to run on ubuntu 8.10.  When I try to run
> unicorn I am getting the following error.
>
> with the following command I get the following error.  Is this because I
> dont have a ruby rails app installed yet?

Yes. unicorn_rails must be run from RAILS_ROOT.

See http://unicorn.bogomips.org/unicorn_rails_1.html

> The other error i get is when I run unicorn with the command line.
>
> unicorn at install01:/app/unicorn/config$ unicorn -c config.ru
> {:daemonize=>false,
>  :unicorn_options=>
>  {:listeners=>[], :config_file=>"/app/unicorn/config/config.ru"},
>  :app=>
>
> #<Proc:0xb7bf2a68@/app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/bin/unicorn:123>}
> I, [2009-11-03T13:03:53.555204 #30820]  INFO -- : unlinking existing
> socket=/app/unicorn/tmp/sockets/unicorn.sock
> I, [2009-11-03T13:03:53.555538 #30820]  INFO -- : listening on
> addr=/app/unicorn/tmp/sockets/unicorn.sock fd=3
> I, [2009-11-03T13:03:53.555596 #30820]  INFO -- : Refreshing Gem list
> Exception `NoMethodError' at config.ru:6 - undefined method
> `worker_processes' for #<Rack::Builder:0xb7a107b8 @ins=[]>
> Exception `NoMethodError'
> at /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/bin/unicorn:130 - undefined method `worker_processes' for #<Rack::Builder:0xb7a107b8 @ins=[]>
> config.ru:6: undefined method `worker_processes' for
> #<Rack::Builder:0xb7a107b8 @ins=[]> (NoMethodError)
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `instance_eval'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in `initialize'
>        from config.ru:1:in `new'
>        from config.ru:1
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/lib/unicorn.rb:697:in `eval'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/bin/unicorn:130
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/lib/unicorn.rb:697:in `call'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/lib/unicorn.rb:697:in `build_app!'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/lib/unicorn.rb:170:in `start'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/lib/unicorn.rb:20:in `run'
>
> from /app/ruby.1.8.7-p174/lib/ruby/gems/1.8/gems/unicorn-0.93.4/bin/unicorn:165
>        from /app/ruby/bin/unicorn:19:in `load'
>        from /app/ruby/bin/unicorn:19
> unicorn at install01:/app/unicorn/config$
>
> Now is this error generanted because it requires a rails envoiroment.

You need a separate unicorn.rb, distinct from your config.ru when
using Unicorn. It appears you are using the proper config option
(worker_processes) but putting it in the wrong file (config.ru).

config.ru defines your app. Unicorn runs your app. The two are
interchangeable, and this is a good thing.

Trying moving your unicorn specific logic into a unicorn.rb and
launching it with `unicorn -c unicorn.rb config.ru`

-- 
Chris Wanstrath
http://github.com/defunkt


More information about the mongrel-unicorn mailing list