Six Tips for Mastering your Procfile

Ah, the glorious Procfile. The starting point for any app running on Heroku and other cloud platforms.

Starting line

Photo by Tim Gouw / Unsplash

At it simplest, the Procfile is where you declare the one or more processes to be run for your app to function. Heroku’s docs do a great job of explaining the Procfile format, so this post will focus on a bit more advanced usage.

These tips are a compilation from my Twitter feed, where I post 🔥 tips on Heroku, Rails, and other dev-related topics.

Let’s start with how you use your Procfile in your local dev environment. One of the benefits of a Procfile is dev/prod parity, so it makes sense to run your app locally using a tool like heroku local that integrates with a Procfile.

Always run your app locally using Procfile for dev/prod parity

If you’re a tmux user and want to take this to the next level, overmind is an awesome alternative.

Running your Procfile with overmind

Dev/prod parity is a worthy goal, but there are often processes you only want to run in development. I’ll throw those into my Procfile as well and simply ignore them in production.

Dev processes in Procfile

Config vars (a.k.a. environment variables) are generally shared amongst all process for your Heroku app, but in your Procfile you can specify per-process configs with shell variable substitution.

Process-specific configs in Procfile

You can also use config vars to skip a process altogether.

Skip a Procfile process based on a config var

Remember that you’re not limited to just one web and worker process. You can add as many distinct processes to your Procfile as you want!

Multiple worker processes handling separate queues

Want more tips like these? You should follow me on Twitter! And if you’re building Rails apps on Heroku, you should check out Rails Autoscale — the best way to autoscale your Rails app.