Heroku | An introduction to Procfile and its use

|
| By Webner

Introduction: We can make our Heroku app run different type of processes by creating a Procfile in the app.
There is a specific structure and syntax that we need to follow while creating a Procfile. Following are the main points to be considered while creating a Procfile:

The Procfile must be placed under root directory of the application. For example if we are creating a cakePHP app then procfile needs to be located inside root folder as : “rootFolderName/Procfile”.
The name of the Procfile must be “Procfile”. We cannot change the spelling or case while creating Procfile.

The Procfile will have process types and an executable command for each process type. The format for writing a process in Procfile is as below:

<process type> : <command>

<process type>: process type is any valid type of process that heroku supports. And it can be any of the following types:- web, worker, urgent worker and clock.

<command>: a command line to launch the process, the command can be any executable command based on a app technology. e.g if we are running CakePHP app the command can be something like:

app/Console/cake opportunity

The above command will be get executed when the process is invoked.

For Example: Below is the Procfile code having two different Process types:

web: vendor/bin/heroku-php-apache2
worker: app/Console/cake opportunity

Checking the status of Process execution: To view the procfile run status and associated logs we can use the heroku logs command as follow:

heroku logs -t --app appName

Leave a Reply

Your email address will not be published. Required fields are marked *