在IronRuby Rack下运行Rails应用程序

5

有人在使用IronRuby吗?

我已经成功在我的本地机器上使用IIS 5.1运行了IronRuby.Rails.Example项目。现在我正在尝试以同样的方式运行自己的演示rails网站。

我的web.config与示例项目略有不同。我尝试仅使用IronRuby 1.0和使用gem安装的内容。

我遇到了以下错误,它并没有给我很多线索:

D:/demo/config/boot.rb:66:in `exit': exit (SystemExit)

尝试了许多不同的方法后,我认为它无法找到gems。我附上了我的web config和ironrack.log。有人可以指出我做错了什么吗?

谢谢!

<?xml version="1.0"?>
<configuration>
    <configSections>
        <!-- custom configuration section for DLR hosting -->
        <section name="microsoft.scripting" type="Microsoft.Scripting.Hosting.Configuration.Section, Microsoft.Scripting" requirePermission="false"/>
    </configSections>
    <system.webServer>
        <handlers>
            <!-- clear all other handlers first. Don't do this if you have other handlers you want to run -->
            <clear/>
            <!-- This hooks up the HttpHandler which will dispatch all requests to Rack -->
            <add name="IronRuby" path="*" verb="*" type="IronRuby.Rack.HttpHandlerFactory, IronRuby.Rack" resourceType="Unspecified" requireAccess="Read" preCondition="integratedMode"/>
        </handlers>
    </system.webServer>
    <system.web>
        <!-- make this true if you want to debug any of the DLR code, IronRuby.Rack, or your own managed code -->
        <compilation debug="true"/>
    <httpHandlers>
      <!-- clear all other handlers first. Don't do this if you have other handlers you want to run -->
      <clear/>
      <!-- This hooks up the HttpHandler which will dispatch all requests to Rack -->
      <add path="*" verb="*" type="IronRuby.Rack.HttpHandlerFactory, IronRuby.Rack" />
    </httpHandlers>
    </system.web>
    <!-- DLR configuration. Set debugMode to "true" if you want to debug your dynamic language code with VS -->
    <microsoft.scripting debugMode="false">
        <options>
            <!-- Library paths: make sure these paths are correct -->
            <!--<set option="LibraryPaths" value="..\..\..\Languages\Ruby\libs\;
                                                  ..\..\..\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.8.6p368\lib\ruby\site_ruby\1.8\;
                                                  ..\..\..\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.8.6p368\lib\ruby\1.8\"/>-->
            <set option="LibraryPaths" value="C:\IronRuby\lib\IronRuby;C:\IronRuby\lib\ruby\1.8;C:\IronRuby\lib\ruby\site_ruby;C:\IronRuby\lib\ruby\site_ruby\1.8"/>
        </options>
    </microsoft.scripting>
    <appSettings>
        <add key="AppRoot" value="."/>
        <add key="Log" value="ironrack.log"/>
        <!-- <add key="GemPath" value="..\..\..\..\External.LCA_RESTRICTED\Languages\Ruby\ruby-1.8.6p368\lib\ruby\gems\1.8"/> -->
        <add key="GemPath" value="C:\IronRuby\Lib\ironruby\gems\1.8\gems"/>
        <add key="RackEnv" value="production"/>
    </appSettings>
</configuration>

=== Booting ironruby-rack at 4/15/2010 1:27:12 PM [DEBUG] >>> TOPLEVEL_BINDING = binding
=> Setting GEM_PATH: 'C:\\IronRuby\\Lib\\ironruby\\gems\\1.8\\gems'
=> Setting RACK_ENV: 'production'
=> Loading RubyGems [DEBUG] >>> require 'rubygems'
=> Loading Rack >=1.0.0 [DEBUG] >>> gem 'rack', '>=1.0.0';require 'rack'
=> Loaded rack-1.1
=> Application root: 'D:\\demo'
=> Loading Rack application [DEBUG] >>> Rack::Builder.new { (
    require "config/environment"

    ENV['RAILS_ENV'] = 'development'

    use Rails::Rack::LogTailer
    use Rails::Rack::Static
    run ActionController::Dispatcher.new
    ) }.to_app exit
    D:/demo/config/boot.rb:66:in `exit': exit (SystemExit)
        from D:/demo/config/boot.rb:66:in `load_rails_gem'
        from D:/demo/config/boot.rb:54:in `load_initializer'
        from D:/demo/config/boot.rb:38:in `run'
        from D:/demo/config/boot.rb:11:in `boot!'
        from D:/demo/config/boot.rb:110
        from C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from D:/demo/config/environment.rb:7
        from C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/IronRuby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from (eval):1
        from C:/IronRuby/lib/ironruby/gems/1.8/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
        from C:/IronRuby/lib/ironruby/gems/1.8/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
        from (eval):0
        from D:\Dev\ironruby\ironruby-ironruby-20bc41b\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:52:in `Execute'
        from D:\Dev\ironruby\ironruby-ironruby-20bc41b\Merlin\Main\Hosts\IronRuby.Rack\RubyEngine.cs:45:in `Execute'
        from D:\Dev\ironruby\ironruby-ironruby-20bc41b\Merlin\Main\Hosts\IronRuby.Rack\Application.cs:68:in `Rackup'
        from D:\Dev\ironruby\ironruby-ironruby-20bc41b\Merlin\Main\Hosts\IronRuby.Rack\Application.cs:32:in `.ctor'
        from D:\Dev\ironruby\ironruby-ironruby-20bc41b\Merlin\Main\Hosts\IronRuby.Rack\HttpHandlerFactory.cs:37:in `GetHandler'
        from System.Web:0:in `MapHttpHandler'
        from System.Web:0:in `System.Web.HttpApplication.IExecutionStep.Execute'
        from System.Web:0:in `ExecuteStep'
        from System.Web:0:in `ResumeSteps'
        from System.Web:0:in `System.Web.IHttpAsyncHandler.BeginProcessRequest'
        from System.Web:0:in `ProcessRequestInternal'
        from System.Web:0:in `ProcessRequestNoDemand'
        from System.Web:0:in `ProcessRequest'
1个回答

3
Exit是在Ruby中编程退出的方法。Rack的思想是作为Ruby Web框架和实际应用服务器之间的中间件。通过解耦,它允许众多Ruby框架(如Rails、Sinatra、Ramaze等)针对单个接口,而众多应用服务器(如Mongrel、带有Passenger的Apache、Unicorn等)则执行相同的操作。IR团队似乎正在尝试让Rack与IIS配合使用。我快速搜索了一下Rails在Rack配置方面的内容,并找到了这个页面。输出结果与你在Rails服务器方法中看到的类似。你可以尝试弄清楚这个结果从哪里来。
require "config/environment"

ENV['RAILS_ENV'] = 'development'

use Rails::Rack::LogTailer
use Rails::Rack::Static
run ActionController::Dispatcher.new
) }.to_app exit

尝试使其更接近指南中的内容。如果您无法在那里找到它,我建议您在IR邮件列表上发布。他们往往非常友好,由于这目前是一个边缘领域,他们可能是唯一拥有足够专业知识来帮助您的人。

祝你好运 :-)


你完全走对了路。我安装了Rack版本1.0.1和1.1.0的gems。我卸载了1.1.0,现在我遇到了路由错误...所以看起来我又走上了通向启蒙之路。 - NotMyself
很高兴我能帮到你 :) - Matt Briggs
@NotMyself - 看来我和你走的是同一条路线;我先遇到了“退出”问题,卸载1.1.0也为我解决了这个问题。你能解决路由错误吗? - Brian Sullivan
1
没关系!我想通了。我只需要在我的development.rb文件中添加以下行:config.action_controller.relative_url_root = "/irails"其中“irails”是我在IIS中的虚拟目录名称。很简单! - Brian Sullivan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接