3

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:\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

Any idea on how to resolve this? Thank you!

aaandre
  • 2,502
  • 5
  • 33
  • 46

3 Answers3

2

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.

Community
  • 1
  • 1
Chuck Vose
  • 4,560
  • 24
  • 31
  • 5
    Thank you. "You can't" is a common answer for anything Ruby related on windows :) – aaandre Dec 04 '09 at 01:16
  • Haha, yeah. It's an unfortunate fact that almost all Rubyists are Mac guys. It's partly because Ruby was used only on little haughty design firms for a long time so that's where the learning-earning is. But I hear it's getting better every day! – Chuck Vose Dec 04 '09 at 02:58
2

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.

Matthieu Rouget
  • 3,289
  • 18
  • 23
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 :)

  • Thank you for replying, I will look into it. Since I have moved to developing in an Ubuntu VM on my Windows workstation. – aaandre Sep 24 '14 at 18:27