代码之家  ›  专栏  ›  技术社区  ›  aaandre

在windows上启动Sinatra应用程序时,猎枪宝石会爆炸

  •  2
  • aaandre  · 技术社区  · 15 年前

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

    windows XP和最新版本的mongrel、sinatra、shotgun。ruby 1.8.6

    运行鸟枪测试_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
    

    有没有办法解决这个问题?非常感谢。

    3 回复  |  直到 15 年前
        1
  •  2
  •   Community CDub    8 年前

    我所能做的就是指给你看 another thread about this

        2
  •  2
  •   Matthieu Rouget    11 年前

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

    require 'sinatra/reloader'
    

    在Windows8.1下工作正常。

        3
  •  1
  •   Vais Salikhov    10 年前

    restart gem fork() . 在您的示例中,您只需替换 具有

    restart ruby test_app.rb
    

    here 欲了解更多信息-希望这对您有用:)