Procfile

Definition

The Procfile is a way to define how the platform will try to start your containers. In this file, you can define all the different process you would like to run in your project. It is commonly used to define how to start workers which will consume asynchronous jobs.

A Procfile is basically a text file using the YAML format describing how to start each type of container for your app. It has to be located at the root of your project. Environment variables will be interpolated.

web: bundle exec rails server -p $PORT -e $RAILS_ENV
worker: bundle exec sidekiq -e $RAILS_ENV

By default, when you first try to deploy your application, we’ll try to launch the web process. We try to determine it without your help, but in some cases it is required to define it, as in the previous example. If your application requires a Procfile and you haven’t defined it, your deployment will fail and a log entry will attest the lack of Procfile.

The standard syntax is:

<container type>: <command>

container type: should contain letters and digits only
command: any command line which can includes environment variables

Using in development

To reduce the environment gap between the development and the production, it is important to execute the same processes in development and in any deployed environment.

To achieve this different tools exist. The most famous is foreman. A little ruby gem executing and displaying the output of all the processes defined in your Procfile.

└> cat Procfile 
web: bin/project
worker: bin/project -worker

└> foreman start
17:52:56 web.1    | started with pid 10663
17:52:56 worker.1 | started with pid 10664
17:52:56 web.1    | 2014/12/01 17:52:56 Listen HTTP requests on :5000
17:52:56 worker.1 | 2014/12/01 17:52:56 Starting Asynchronous worker

To install it: gem install foreman

Alternatives to foreman:

schedule 01 Dec 2014