Jun 11, 2014 | foreman, development, procfile

Using a Procfile to streamline your local development

!
Warning: This post is over a year old. I don't always update old posts with new information, so some of this information may be out of date.

I'm currently working on an app that I'm developing with the Ionic framework. As is common lately, I have multiple processes I want running concurrently as I develop the app: I want to have Gulp running while I develop in order to manage my assets, and I want a quick and dirty local web server to preview it.

Every time I opened up my terminal to work on this site, I'd open up three tabs. One for gulp, one for the server, and one for general folder management: git, ls, cp, etc. And I'd have to re-create this tab layout every time.

(Note: I know one of the solutions for this would be to start using tmux, and the moment I do I'll write it up.)

Introducing Foreman

Procfile running

But there's a simple solution for this: Foreman. Foreman is a tool that allows you to declare the processes that are necessary in order to run your app in a file called a Procfile. Then just run Foreman and it'll start up all of your processes together, at once, with a nice color-coded output.

Installing Foreman

Assuming you have Ruby running on your system, simply run gem install foreman from anywhere on your commandline and you're good to go.

Creating your first Procfile

A Procfile is comprised of lines that follow this syntax:

process_nickname: shell_command_to_run_process

So in order to create a process nicknamed "gulp" which runs gulp watch, I'd add the following line to my Procfile:

gulp: gulp watch

That's it! You can run as many of these as you want at a time.

My Ionic Procfile

So, here's my Procfile for Ionic:

gulp: gulp watch
serve: ionic serve

Running Foreman

Now that I have a working Procfile (named Procfile) in the root of my project, I simply run foreman start and I can see the processes start up and echo out their notices. I can quit out at any point with CTRL-C.

Personally, I like to run this from my IDE's built-in Terminal, and then if I use my IDE's folder/file management and VCS (Git) tools, I can completely stay out of the Terminal while I develop this app. Less alt-tabbing means more focus, which I can't complain about!

Isiphetho

That's it! Go forth and Procfile!

Questions? Favorite procfiles you want to share? Hit me up on Twitter.


Comments? I'm @stauffermatt on Twitter


Tags: foreman  •  development  •  procfile

Subscribe

For quick links to fresh content, and for more thoughts that don't make it to the blog.