Engineering April 13, 2018 3 min read

Managing several Heroku apps more easily

Photo by Cyril Saulnier on Unsplash

This article is aimed at developers or team leaders who have started using Heroku and need to handle, maintain and deploy several heroku apps at the same time. So, if you are that person, I hope this article will help you tackle this more easily.

When you have several projects, identifying some aspects that can be standardised will help you keep everything under control with less work. Also your team will work more smoothly if it understands and adheres to those standards.

Git Flow

The first part of this process starts with standardising Git. You should already be acquainted with GIT Flow, so naming your branches develop, master in all the projects is a must have. If you have feature branches, create them all the same way, so that it is easier not only for you but your team as well.

Next is how to correctly deploy to Heroku. You should add the heroku remote repositories to your Git client. Usually, in Heroku, you will have a staging environment and a production environment. So name these remotes staging and production respectively.

By doing this in all the projects you immediately get rid of the need to know the application names for each one. Typing staging is a lot easier than <your-app-name>-staging.

Heroku Cli

Heroku Cli is a powerful tool that you should master. Learn the basic commands and it will help you a lot.

If you named the remotes staging and production then you can use heroku cli with the -remote <remote_name> flag instead of -a <application_name>

For example, when you have an error in the staging environment and you want to the check the logs:

Code
$ heroku logs -t -a <my_application_name>

can easily be replaced with:

Code
$ heroku logs -t --remote staging

This command can be reused in all the projects. No need to remember all the application names, and with repeated use it becomes second nature.

This also works for the console command

Code
$ heroku console --remote staging

Get staging database to local for debugging with staging data? No worries:

Code
$ heroku pg:pull DATABASE_URL <local_db_name> —-remote staging

Fuzzy search

As you can see, setting up shell aliases for these commands is easy if you want to. That said, I have never felt the need to do so because I use fuzzy search over my command history, which helps to reuse previous commands.

Parity

I can’t talk about Heroku command line helpers without mentioning Parity. Parity has several shell commands that will speed up some common tasks related with backing up databases and syncing databases locally. I have never used it myself but it is also a valid option.

That’s all for now! I hope this will serve you as a useful entry point to start managing several apps in Heroku.

I love building products and I found my place to do so at Runtime-Revolution. If you are interested in who we are and what we do, make sure to reach out!

Runtime RevolutionWe are Rails, mobile and product development experts. We can build your product or work with you on your project.www.runtime-revolution.com