【问题标题】:shotgun gem explodes when starting a Sinatra app on windows在 Windows 上启动 Sinatra 应用程序时,shotgun gem 会爆炸
【发布时间】:2009-12-04 00:57:20
【问题描述】:

Sinatra 应用程序:

require "rubygems"
require "sinatra"

get '/' do 
    "Hello world. It's #{Time.now} at the server!"
end

带有最新版本的 mongrel、sinatra、shotgun 的 windows XP。红宝石 1.8.6

运行 shotgun test_app.rb 结果


C:\Files\sites\sinatra>shotgun test.rb
== Shotgun starting Rack::Handler::Mongrel on localhost:9393
Thu Dec 03 16:51:37 -0800 2009: Read error: #<NotImplementedError: fork() functi
on is unimplemented on this machine>
c:/ruby/lib/ruby/gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:26:in `fork'
c:/ruby/lib/ruby/gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:26:in `call!'
c:/ruby/lib/ruby/gems/1.8/gems/shotgun-0.4/lib/shotgun.rb:15:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/content_length.rb:13:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/chunked.rb:15:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:61:in `process'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:159:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:158:in `process_client'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:285:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `initialize'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `new'
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.5-x86-mswin32-60/lib/mongrel.rb:268:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/handler/mongrel.rb:34:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/shotgun-0.4/bin/shotgun:129
c:/Ruby/bin/shotgun:19:in `load'
c:/Ruby/bin/shotgun:19

关于如何解决这个问题的任何想法?谢谢!

【问题讨论】:

    标签: windows ruby sinatra shotgun


    【解决方案1】:

    我能做的最好的就是将您指向another thread about this。 Shotgun 需要仅在 *nix 系统上可用的 fork。如果您想提交补丁,甚至还有一些关于如何在本地进行的操作。

    【讨论】:

    • 谢谢。 “你不能”是 Windows 上任何与 Ruby 相关的常见答案 :)
    • 哈哈,是的。不幸的是,几乎所有的 Rubyist 都是 Mac 用户。部分原因是 Ruby 长期以来只在小傲慢的设计公司中使用,所以这就是学习收入的地方。但我听说它每天都在变好!
    【解决方案2】:

    一个简单的方法是使用 sinatra/reloader。安装 sinatra/contrib gem 并将扩展名添加到您的主文件中:

    require 'sinatra/reloader'
    

    在 WIndows 8.1 下运行良好。

    【讨论】:

      【解决方案3】:

      你可以试试restart gem——它原本打算在Windows上使用,所以它不使用fork()。在您的示例中,您只需将 shotgun 替换为 restart ruby​​,如下所示:

      restart ruby test_app.rb
      

      请参阅here 了解更多信息 - 希望这对你有用:)

      【讨论】:

      • 感谢您的回复,我会调查的。自从我开始在我的 Windows 工作站上使用 Ubuntu VM 进行开发。
      猜你喜欢
      • 1970-01-01
      • 2011-02-19
      • 2011-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多