Easy Button for Mongrel
July 21st, 2006
If you’ve hopped on the Mongrel bandwagon, you know how convenient and efficient the Mongrel server can be for running Ruby on Rails applications.
The only thing that’s not so convenient about Mongrel is the way you start it when you’re working in development mode. Typing that long command (mongrel_rails start -d -p 3000 -e development) every time you want to start your web app can be a real pain.
So I came up with this quick shell script (UNIX/Linux only – sorry Windows folks) that does the same thing as the script/server command.
The script/mongrel file
#!/bin/sh
/usr/local/bin/mongrel_rails start \
-d \
-p 3000 \
-e development \
-c /path/to/your/web/app
To use it:
- Go to your Rails app and make a file in your script directory called
mongrel(no file extension – just “mongrel”). - Paste the above code inside the file, modifying it as necessary. Save the file.
- Go out to your terminal, and navigate to the root of your web app.
- Run
script/mongrel. - That’s it! Your web server should be running! Test it by browsing to http://0.0.0.0:3000.
To shut down the web app, just run mongrel_rails stop from the root of your web app.
4 Responses to “Easy Button for Mongrel”
Sorry, comments are closed for this article.
July 21st, 2006 at 03:19 AM Nice! FYI, in Edge Rails "script/server" will use Mongrel, if you've got it installed. (http://dev.rubyonrails.org/ticket/5475)
July 21st, 2006 at 03:33 AM Cool - that's a good reason to upgrade to Edge Rails.
July 24th, 2006 at 02:28 PM On Edge Rails, script/server will run mongrel like this if its installed.
July 25th, 2006 at 04:45 AM Thanks guys - I'm playing with Edge Rails now, and it does indeed work as advertised. Compared to the standard Lighttpd script/server, Mongrel seems _fast_.