-
Notifications
You must be signed in to change notification settings - Fork 66
Process types and the Procfile
Procfiles were introduced by Heroku as a mechanism for declaring what commands are run by your application. See this link for more details.
Process types are declared in a specific file named Procfile
. It comes from the Heroku way of doing things, and is a simple text-based file spercifying a mapping between process names, and how those process are launched.
For instance, most web applications have at least a web
process, which is usually a server daemon being able to serve HTTP requests for the application. Applications may also have a worker
process, which is used to run background job processors, such as Sidekiq or Resquein the Ruby world.
Process names can be arbitrary, although it is expected that the web
process specifies the main process of your application.
Any process declared in the Procfile
can be launched using the dedicated command line tool that comes with each package.
Assuming you have declared the following Procfile
:
# Procfile
web: bundle exec rails s -p $PORT
worker: bundle exec sidekiq
You would be able to launch any of the web
or worker
processes in two way:
- as a foreground process (e.g. an interactive console)
- as a background process (e.g. your web processes, or background job processes)
sudo my-app run web
To quit the process, you would hit CTRL-C.
sudo my-app scale web=1
Using the scale
command will register the process with your init system.
As such, to manage the process, you would then use the service
utility from your system:
sudo service my-app-web stop|start|restart|status