Running multiple ruby projects with foreman and subcontractor

We have a suite of ruby applications at
Braintree. There are many times when we need to run more than one of these apps at the same time. For
example, we might need to run our login app in addition to whichever app
we are working on.

We use foreman as our process
launcher, but foreman does not handle running other projects in other
rvm gemsets (and possibly ruby versions). One of my fellow developers,
Tony Pitluga, released a gem called subcontractor that handles these cases.

For example, our Procfile looks like:

app: rails server  
login: subcontract --rvm "--with-rubies rvmrc" --chdir ../login --signal INT -- rails server -p 4000  

This runs the current app on port 3000 and the login app on port 4000
with a different home folder, ruby and gemset. The login line is roughly
equivalent to running
cd ../login && rvm --with-rubies rvmrc exec rails server -p 4000 The option --with-rubies rvmrc tells rvm to use the .rvmrc file to load
the correct ruby and gemset. If a project doesn’t have an .rvmrc file,
you can specify the ruby version:

another_app: subcontract --rvm ruby-1.8.7-p249@another_app --chdir ../another_app --signal INT -- rails server -p 4000