Moving to Phusion Passenger
This week I have moved my Ruby websites (which were previously running on Mongrel) to the Phusion Passenger Apache2 module. I have lived without apache for about a year, but I am really happy I switched back to it again. I am still using Nginx as a front-end proxy to serve static assets.
I am very pleased with Passenger because it makes deployment a lot easier! Basically, all Capistrano needs to do now for a deployment is move your app into the DocumentRoot and touch a "restart.txt" file. It supposedly works with any Rack-based web framework. I am using it with Merb and Rails.
I have more available memory and CPU cycles because there are no idle mongrels running, and availability is increased because new instances of the apps are spawned as needed (where memory is shared between multiple instances of an app).
Life is good with passenger!
I've bought a domain
I’ve finally bought my own domain, aczid.nl. Besides the blog, I want to host my music, code and other creations here.
All you readers out there can visit my blog at blog.aczid.nl.
I would like to thank Lasert for providing me with a 2 GHz/256 512 MB Xen slice on a big unclogged eweka tube. It’s a fun and stimulating experience to set up your own front-end/proxy server, subversion, et cetera.
I plan to do most if not all of the site in Ruby on Rails. The blog is served using Nginx, Mongrel and Typo.
Easy UML from your rails app
If you're a programmer, chances are you're not a big fan of making software diagrams. Writing code is much more fun!
Of course, if you remain agile you can do a whole project by yourself. But say you are using rails in a professional environment? Sooner or later, you're going to want to show someone a global overview of how your app is structured.
In my opinion, diagrams are good to reach agreement on the design of software.
It should be easy to maintain,
it shouldn't all be written in advance, and
it definetly shouldn't be a product in and of itself.
Since we're lazy ruby programmers, why not turn the waterfall upside down and generate diagrams from our code?
Go and get Railroad. Its needs Graphviz to work. You can get railroad as a gem and graphviz is hopefully in your package manager.
After getting those, just try it out on your current project!
Generate a model diagram from your app including non-ActiveRecord models and inheritance.
$ railroad -M -a -i | dot -Tpng > doc/models.png
Generate a controller diagram.
$ railroad -C | neato -Tpng > doc/controllers.png
Check out the railroad site for more info, code examples and some sample output. The output actually looks pretty neat. Here's what it generates for Typo.
Backgroundrb is pretty cool stuff
For my employer I'm developing a rails app that needs to do a lot of RPC calls in the background. It's not really putting strain on our servers, but that sort of stuff will always take longer than you want it to. At first I just wanted PHP-style output buffering. However that doesn't scale too well with rails setups being the way they are.
To improve stability and reliability, we need to seperate it from the rails environment copmletely.
Enter Backgroundrb.
Backgroundrb lets you do some heavy lifting in the background. It's basically a separate server that allows you to run worker threads.
Now you might ask: "How does this fit into rails?". Well, it goes a little something like this...
The worker (put this in /lib/workers)
class ExampleWorker < BackgrounDRb::Worker::RailsBase
def do_work(args)
results[:some_string] = "I'm robust!"
end
end
ExampleWorker.registerRequest for heavy lifting coming in:
def background_action
session[:job_key] = MiddleMan.new_worker(:class => :example_worker, :args => {:arg => params[:some_arg]})
endResponse going out (this could be used in an AJAX calback action):
def callback
@result = MiddleMan.worker(session[:job_key]).results[:some_string]
end
It's so simple I couldn't have thought it up!
You can name your worker jobs by passing :job_key in the :args hash.
Let me speculate that this will become a widely used plugin as rails is receiving more and more commercial adoption. Who knows, it might even get merged into rails core! It definetly blows PHP's output buffering out of the water!










