Topic: Newbie - ROR3 deploying to windows

Hi,

I am very new to RoR development, most of my experience is in .NET . I am trying to deploy a ROR3 website onto a windows machine. After reading around I decided to try using Mongrel + Apache (is this the best setup?)

I struggled to find any up to date guides and eventually ran into problems. I installed the mongrel and mongrel_service gems and managed to start a few mongrel services using:-

mongrel_rails service::install –N mongrel_MyApp1 –p 3001 –e production –c c:\Sites\MyApp
mongrel_rails service::install –N mongrel_MyApp2 –p 3002 –e production –c c:\Sites\MyApp
mongrel_rails service::install –N mongrel_MyApp3 –p 3003 –e production –c c:\Sites\MyApp

However when I navigate to localhost:3001 in my web browser I cannot connect. When I launch my apache server I just get a 502 proxy error. I can see the services in windows and start and stop them.

I have setup my apache http-vhosts.config as follows

NameVirtualHost *:80

#Proxy balancer section (create one for each ruby app cluster)
<Proxy balancer://mongrel_cluster>
    BalancerMember http://localhost:3001
    BalancerMember http://localhost:3002
    BalancerMember http://localhost:3003
</Proxy>
<VirtualHost *:80>
    ProxyPass / balancer://mongrel_cluster/
    ProxyPassReverse / balancer://mongrel_cluster/
    ProxyPreserveHost on
</VirtualHost>


Any advice would be very helpful, is mongrel+apache the best setup for windows? What might I be doing wrong with my mongrel setup?

Re: Newbie - ROR3 deploying to windows

Also noticed that when I run 'mongrel_rails start' I get the following error:-

** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- dispatcher (LoadError)
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `block in require'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:236:in `load_dependency'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/dependencies.rb:251:in `require'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:148:in `rails'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in `block (2 levels) in run'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in `call'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in `listener'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in `block in run'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in `call'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in `initialize'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in `new'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in `run'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/command.rb:210:in `run'
        from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282:in `<top (required)>'
        from c:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in `load'
        from c:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in `<main>'

Re: Newbie - ROR3 deploying to windows

Getting closer I think, I added eventmachine and dispatcher to my Gemfile, now getting this error in my mongrel.log after starting the services

c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/core_ext/hash/reverse_merge.rb:12:in `<class:Hash>': Interrupt
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.1/lib/active_support/core_ext/hash/reverse_merge.rb:1:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:1:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:1:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails.rb:10:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails.rb:10:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/all.rb:1:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1/lib/rails/all.rb:1:in `<top (required)>'
    from C:/Sites/ADF_Reporting/config/application.rb:3:in `require'
    from C:/Sites/ADF_Reporting/config/application.rb:3:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from C:/Sites/ADF_Reporting/config/environment.rb:2:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:147:in `rails'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:116:in `block (2 levels) in run'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in `call'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:149:in `listener'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:102:in `block in run'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in `call'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/configurator.rb:50:in `initialize'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in `new'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:86:in `run'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/command.rb:210:in `run'
    from c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/bin/mongrel_rails:282:in `<top (required)>'
    from c:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in `load'
    from c:/RailsInstaller/Ruby1.9.3/bin/mongrel_rails:23:in `<main>'

Re: Newbie - ROR3 deploying to windows

Ok, can now start the service and the server runs, but when I go to the page I get the following error:

2012-05-16 09:03:34 +0100: Error calling Dispatcher.dispatch #<NameError: uninitialized constant ActionController::CgiRequest>
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:76:in `block in process'
<internal:prelude>:10:in `synchronize'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:74:in `process'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:165:in `block in process_client'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `process_client'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:291:in `block (2 levels) in run'

Re: Newbie - ROR3 deploying to windows

To answer you first question
don't use mongrel for a live environment and don't use Windows to host a rails app! (Why anyone would even think of using windows to host a website is way beyond me)

Windows is ok for dev purposes but can be slow (Linux is way better)
The best server configuration I have found is Linux with nginx and unicorn
You use nginx instead of apache - It's much lighter weight and very fast plus even better in a linuc environment it can be easily configured to use unix sockets and unicorn instead of mongrel/webrick/passenger etc...

It's an awesome combination.
You might be interested in looking at some of the newer railscasts on deployment
http://railscasts.com/episodes/335-deploying-to-a-vps
http://railscasts.com/episodes/337-capistrano-recipes

There are other casts so have a good search through them all

Mongrel has problems with the latest rails 3 setup and for dev purposes you would be better using webrick , thin or unicorn - thin is also awesome but I prefer unicorn.

You have a steep learning curve here, it might be worth your while talking to the guys at railsplayground hosting. They will give you extremely affordable hosting and are very very helpful with live 24x7 chat and ticketing system with techinical staff ho totally understand hosting a rails app, they even wrote my first capistrano recipe for me when I was first starting out.

Hope that helps

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)