Codementor Events

The Heroku Procfile

Published May 01, 2022
The Heroku Procfile

Procfile is a file that specifies the commands that are executed
by an Heroku app on startup. While it is not necessary to include a Procfile
for Heroku deployment, a Procfile allows for more startup configuration
and the definition of multiple processes that run separate dynos.

Procfile

The Procfile (literally a file titled Procfile) is located in the root of an application's file system, and can be used to specify a variety of processes.
Each Heroku dyno started the app
belongs to one of the declared process types.

Processes are listed within the Procfile on separate lines:

<process type>: <command>

You can refer to an applications config variables in the command using $ syntax.

web: bundle exec rails server -p $PORT

The web Process Type

The process type web is special to Heroku.
It is the only process type that can receive external HTTP traffic.

Example Procfile with many processes:

web:           bundle exec rails server
release:       ./release-tasks.sh
worker:        env QUEUE=* bundle exec rake resque:work
deliveryworker:  env QUEUE=delivery bundle exec rake resque:work

Scale the Processes

Scaling the process implies running the configured number of dynos
with the specified command. The commandline utility heroku ps is used for this.

To scale the processes within the given example Procfile:

heroku ps:scale worker=1 urgentworker=3

Procfile and heroku.yml

The Procfile is not required if a heroku.yml file is used as the build manifest.
Read more about the heroku.yml in the Resources.

Procfile - https://devcenter.heroku.com/articles/procfile

heroku.yml - https://devcenter.heroku.com/articles/build-docker-images-heroku-yml

Discover and read more posts from Alexa Anderson (Popular Demand)
get started
post commentsBe the first to share your opinion
Show more replies