Controlling Database Servers for a more efficient MacBook

Having a quick development environment means, obviuosly means being able develop ideas quicker. It should be in every programmers interest to understand the impact of project dependencies on speed and effiecentcy. Database servers are things we all need running when we're working, but rarely do we turn thme off when we're not. They just sit in the background. Now, it wouldn't be such an issue if it was only one, say Postgres, but recently i've also been using MySQL, Redis, Solr … to name a few, but still way too many!

One big issue is that most Database servers assume they're the only one you have installed, and asume you want them running all the time. Case in point, installing Postgres via HomeBrew, give you instructions to setup Launch Control to automatically start Postgres on boot, or it porovides you the command to run Postgres as a Daemon. Personally, non of these makes much sense from a development point of view. I want to run Database in much the same way as I run developemnt webservers, spin them up for coding, then kill them when i'm done.

Enter Foreman

Foreman is a Process Manager, when started, it reads from a Procfile and fire up the processes defined. This means I can run Foreman, which will then run all my project dependencies, including database server.

web: unicorn
database: Postgres -D /usr/local/var/postgres
delayed_job: ...

For me, including all my project runtime dependencies, including databases, into a process manager means I know that what I'm running in development is as close as possible to production (without using virtual machines). As a bonus, it also means i can turn off all the background daemons like Postgres or MySQL when I'm not doing any coding, which means my aging MacBook runs a bit smoother.

About the Author

Phil Balchin is a full-time software developer at Zendesk, previously at Heroku/Salesforce, and Kyan, as well as a part-time photographer living in Guildford, Surrey, UK.

facebook.com/phil.balchin | instagram.com/maniacalrobot | last.fm/users/maniacalrobot | picfair.com/maniacalrobot | maniacalrobot.tumblr.com | twitter.com/maniacalrobot

Related Posts

Recent Posts