And once you understand what is Mongrel you'll have the strong desire to shout it loudly - as many times as possible, just like I'm feeling now! Like "how come I hadn't found this before!? where have I been for the last months?".
For those of you which do not understand my sudden explosion of joy (why is she shouting about dogs? is she now going to talk about dogs every day? etc), I'll explain you what Mongrel is and why it's so extremely useful, apart from lovely.
And starting your app, locally, is so easy! ruby script/server and you're done! "Welcome Aboard: You're riding the rails".
Ok. Now go and install it in your favourite host. No one moves - suddenly silence dominates what was an animated and cheered crowd. Why?
Because installing a Rails application in a usual web server is a Pain In You Know Where...
PHP is so popular because there are a couple of fast modules for Apache (mod_php4 and mod_php5) which make running any php script through a server extremely easy. But the ruby module for Apache (mod_ruby) seems to be the most unreliable stuff I have heard of in a long time. So that's why we were told to use another server - Lighttpd with FastCGI and the Ruby module for FastCGI. The problem with it is that it is complex. You need to configure Lighttpd, using another port, proxy it through Apache, create a cron process which takes care of the process and makes sure it will be running even if the server is restarted or the process killed, etc.
Summarising: I spent like two weeks trying to understand how to deploy an application in my hosting. At last it worked but I'm not quite sure how I did it.
But then Mongrel arrived. I had heard about it repeatedly these past months. Everybody talks a mix of capistrano-mongrel-blabla. I found out about Capistrano on the past LRUG meeting, and now I wanted to know what was that mongrel thing. And ooooohhh aaaah!! it is "like a webrick on esteroids", a fast ruby server that you can use in your favourite host, as easy as using webrick.
So, instead of doing
ruby script/serveryou would do
mongrel_rails startAnd voila:
Starting Mongrel listening at 0.0.0.0:3000 Starting Rails with development environment... Rails loaded. Loading any Rails specific GemPlugins Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). Rails signals registered. HUP => reload (without restart). It might not work well. Mongrel available at 0.0.0.0:3000 Use CTRL-C to stop.And you're riding the rails again :)
The best of all is that you can use it the same way in your favourite-host-with-mongrel, which luckily seems to be the case of mine. You just need to add a cron line for making sure that the process is alive (or the application won't work!), and then you can go for as much complexity as you want, like configuring a "cluster" of mongrel's (for increasing performance), adding plugins, making apache serve images and static content, etc.
I still haven't tried it in the live server, just locally, but it is really faster than WEBrick. Reading the documentation, it even gives you support for running the applications in the same domain but different paths. Like mydomain.com/app1path/ and mydomain.com/app2path. That's very cool - I really hate setting up subdomains because there can't be anything easier than creating a new directory in your web.
And the dog pictures, aren't they lovely?
I absolutely dig Mongrel!