From: David Masover Date: 2009-11-27T12:27:51+09:00 Subject: Re: Ruby a good choice for CGI? On Thursday 26 November 2009 11:03:41 am Nick Dr wrote: > = > > > That sounds tailor-made for Sinatra. However, you should learn something > > about > > REST, first -- are you sure POST is appropriate? > > Ok I tried sinatra. It seems like it fires up webrick on port 4567, so I > take it there's some config file I need to mess with, or my hosting > provider deals with so it'll run on Apache instead? Well, yes and no. Sinatra by default fires up on 4567 using supported servers (webrick, mongrel, etc). However, it is a Rack app, and you can configure a rackup file to load your app via anything that does Rack. So they could use Apache or Nginx (via Passenger), or they could use any of the standalone Ruby servers behind Apache or Nginx, or they could have some custom setup. The point is that Rack is the standard modern way of connecting a webserver to a Ruby web app/framework. > Also, I can hit my sinatra ruby script from my browser, but when I tried > to hit it from a jQuery AJAX request, I get nothing back and the sinatra > console says that it was an OPTIONS request instead of the GET request > it reports when firefox asks for the page. Quick question: What browser? I had a similar issue with a Chromium build. One possible test: Run something like netcat locally, so you capture the raw traffic. I very much doubt Sinatra is wrong -- I bet your browser is (erroneously) sending OPTIONS instead of GET. > > FastCGI is obsolete, so scratch that. > > The host I was considering, HostingRails, says they'll do a FastCGI > deployment for me. Do they also support Rack? > Are you sure FastCGI isn't a good option for this? No, but I'm sure it's a weird hack, I doubt it really performs well (or people wouldn't have started using Mongrel in the first place), and I wouldn't trust a host which _only_ supported FastCGI as an option. Check that they'll run an arbitrary Rack app. > > Passenger and mod_ruby are essentially the same thing, IIRC. But my > > understanding is that Passenger works with Rack, which doesn't feel at > > all > > like CGI. So these might be deployment options, but they have nothing to > > do > > with how you write and develop your app. > > So I can just use the Sinatra lib to route the request, deal with > cookies and sessions, and then hand it to my hosting provider and > they'll set it up properly? Hopefully. That's the point of Rack, anyway.