I have a Rails 3.2.3 app (ruby 1.9.3p125) deployed on a Windows 2003 R2 SP2 server, (don't ask). This is my Gemfile:

gem 'mysql2'
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
gem 'pdf-toolkit', "~> 1.0.0.rc1"
gem 'mongrel', '>= 1.2.0.pre2'
gem 'dispatcher'

I run Apache 2.2, and have two mongrels running as Windows services. Apache boots fine, and no errors are reported. The app is running. it simple does some pdftk form filling and sends a pdf file, i.e.:

send_file(....)

In development, I get the correct pdf, in production on windows, I get an empty pdf, and this in my error.log:

2012-05-23 10:08:42 -0700: Error calling Dispatcher.dispatch #<NameError: uninitialized constant   ActionController::CgiRequest>
c:/ruby193/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:/ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel/rails.rb:74:in `process'
c:/ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:165:in `block in process_client'
c:/ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `each'
c:/ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:164:in `process_client'
c:/ruby193/lib/ruby/gems/1.9.1/gems/mongrel-1.2.0.pre2-x86-mingw32/lib/mongrel.rb:291:in `block (2 levels) in run'

I had this running with Rails 2.3.8 and Ruby 1.8.7, the Apache config hasn't been changed since it ran correctly, so I don't think it's related to the Apache config, I'm sure it's related to the new mongrel stuff I had to add due to Rails 3.

UPDATE:

I gave up, and tried it using thin, works fine.

Seeing as most of the posts about installing thin on windows were from the 3.0.x timeframe. I'll give a little refresher as of 3.2.3 and Ruby 1.9.3.

You still have to install thin in two passes

gem install eventmachine --pre
gem install thin

You have to have have ruby installer DevKit installed

After testing, I re-did my Apache config to use thin:

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName pdftk.neeis.com
  DocumentRoot E:/Apache/pdftk/public/
  RewriteEngine On
  <Proxy balancer://thinservers>
    BalancerMember http://127.0.0.1:3005
    BalancerMember http://127.0.0.1:3006
  </Proxy>
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*) balancer://thinservers%{REQUEST_URI} [P,QSA,L]
  ProxyPass / balancer://thinservers/
  ProxyPassReverse / balancer://thinservers/
  ProxyPreserveHost On
  ProxyPass /images !
  ProxyPass /stylesheets !
  ProxyPass /javascripts !      
  <Proxy * >
    Order Deny,Allow
    Allow from all
  </Proxy>
  ErrorLog E:/Apache/Logs/error.log
  CustomLog E:/Apache/Logs/access.log combined
  LogLevel debug
</VirtualHost>

Then came the tedious task of turning the thin into windows services, had to install windows 2003 Resource Kit, copy svrany.exe to System32, use sc command to create the services, then do some regedt32 hackery. But, it works!

有帮助吗?

解决方案

edited:

Some gems do not support Rails 3 yet, try Thin.

As far as I know, mongrel_cluster does not support Rails 3 yet. Fastest solution is to switch to Thin, it supports multiple Rails instances and it's configuration file is very similar to Mongrel's one.

credit: https://stackoverflow.com/a/5660824/643500

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top