You’ll be accustomed to using rails server or the like to boot your Rails application in development. With that simple command you have everything you need, typically running on localhost:3000. But if your API and UI are in separate directories or even separate repositories you’ll want a way to boot them together easily so you aren’t navigating around projects just to launch processes.

You’ve probably seen or used Foreman if you’ve ever deployed to Heroku, or if you use other background services and boot them together with your development server (e.g. Sidekiq, Sunspot, etc). Foreman is awesome at solving just this problem (multi-process management). But Foreman wasn’t designed for processes outside of a single directory, so you’ll need one more piece.

Enter Subcontractor, a gem that enables Foreman to manage processes outside of the Procfile’s directory. It is even aware of RVM, if you haven’t switched to rbenv yet ;). Using Foreman and Subcontractor you can put together a Procfile that will run your API on one port and your UI on another with just one simple command. Here is an example from a recent project we’re working on at Lockstep. Enjoy!

api: subcontract --chdir api -- bundle exec rails s
sidekiq: subcontract --chdir api -- bundle exec sidekiq
ui: subcontract --chdir ui -- local_server