In my last post, I went through the process of setting up Sidekiq to run background jobs in my app. In order to run background processes, separate processes need to be started. Spinning up these separate processes can be tedious, manually starting each one. It’s no longer as simple as running rails s.

Enter Foreman

Foreman is a Ruby gem that is aimed at making developing locally with multiple processes as easy as running one command. It does so by managing your app through a Procfile:

web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
worker: bundle exec sidekiq -e development -C config/sidekiq.yml 
redis: redis-server

Your Rails project doesn’t come with a Procfile out of the box, so you can create one in the root of your project directory. It’s just a plain text file, so no file extension.

The above are commands that you would normally have to run manually in your terminal. By running foreman start, all of the processes specified in your Procfile are automatically started. Also, you aren’t restricted to what I’ve written in this Procfile - you can run any arbitrary process, like an API caller.