【问题标题】:Rails 3 - Windows + Mongrel (Error with dispatcher)Rails 3 - Windows + Mongrel(调度程序出错)
【发布时间】:2012-05-23 20:49:00
【问题描述】:

我正在尝试将 rails 3 应用程序部署到 windows 机器(是的,它必须是 windows,我不能使用 linux)

我决定尝试使用 Mongrel + Apache(如果有人知道可行的设置,我愿意尝试其他设置)。

我已经安装了 mongrel,我可以运行 rails server mongrel 并正常运行我的应用程序。但是,当我尝试使用

将 mongrel 作为 Windows 服务启动时
mongrel_rails service::install -N mongrel1 -e production -p 3001 -c mydirectory`

我遇到了麻烦。服务器启动正常,但是当我尝试进入网页时,我的mongrel.log 文件中生成了以下错误。

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'

我已尝试阅读此内容,但所有设置指南似乎都过时了。

【问题讨论】:

    标签: ruby-on-rails windows mongrel


    【解决方案1】:

    我正在使用 Apache + Mongrel 在 Windows (Win7) 上运行 Rails 3 应用程序。这也许是另一种方法。在 httpd.conf 中,我将 DocumentRoot 设置为我的 rails 应用程序的路径。然后将 Directory 标记设置为 Document Root 的任何内容。然后添加一个VirtualHost标签如下:

    <VirtualHost localhost:80>
      Servername YourAppServer
      DocumentRoot "same path as before"
      ProxyPass / http://localhost:3000/
      ProxyPassReverse / http://localhost:3000/
      ProxyPreserveHost On
    </VirtualHost>"
    

    ServerName 值我认为是任意的。

    您还需要添加: LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so

    我想如果您使用端口 3001 而不是 3000,则可以进行适当的替换。

    然后使用“rails server -e production -p 3001”启动所有内容(从您的应用文件夹)(Apache 应该已经在运行)

    【讨论】:

    • 感谢您的回复,我了解到 mongrel 一次只能处理一个请求,因此最好设置 3 个 mongrel 实例并使用 apache 在它们之间分配请求。我正在尝试将 mongrel 实例作为 Windows 服务启动,这样我就不必一直打开 3 个控制台窗口。我可以按照您的描述启动一个杂种服务器,但我不能将它作为寡妇服务启动。
    猜你喜欢
    • 2011-06-22
    • 1970-01-01
    • 1970-01-01
    • 2011-03-17
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 2010-09-07
    • 1970-01-01
    相关资源
    最近更新 更多