English 中文(简体)
shotgun gem explodes when starting a Sinatra app on windows
原标题:

Sinatra app:

require "rubygems"
require "sinatra"

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

windows XP with latest version of mongrel, sinatra, shotgun. ruby 1.8.6

running shotgun test_app.rb results in


C:Filessitessinatra>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

Any idea on how to resolve this? Thank you!

最佳回答

Best I can do is point you to another thread about this. Shotgun requires fork which is only available on *nix systems. There s even a bit about how to do it natively if you feel like submitting a patch.

问题回答

An easy way to go is to use sinatra/reloader. Install the sinatra/contrib gem and add the extension to your main file:

require  sinatra/reloader 

Works fine under WIndows 8.1.

You can try the restart gem - it was intended to be used on Windows, so it does not use fork(). In your example, you would simply replace shotgun with restart ruby, like this:

restart ruby test_app.rb

See here for more info - hope this works for you :)





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签