The Procfile specifies the commands that are executed by the app upon startup. You can use the Procfile to declare a variety of process types, including:
- Your application's web server
- Multiple types of worker processes
The Procfile is always a simple text file that is named Procfile without a file extension. For example, Procfile.txt is not valid.
You can pass the Procfile when deploying your applications using the --procfile flag alongside the ketch app deploy command.
The Procfile must live in the root directory of the application. It will not function if placed anywhere else.
The Procfile declares each process and types on individual lines, each with the following format:
An example of a Procfile should be similar to the output below:
web: gunicorn -w 3 wsgi
- process-type: is an alphanumeric name for your command, such as web, worker, urgent worker, and so on.
- command-to-execute: indicates the command that every process type should execute on startup.
The name is a string that may contain alphanumerics and underscores and identifies one type of process. A command is a shell command line that executes to spawn a process.
The web process type is special. It is the only process type that can receive external traffic from the Ketch routers. If your application includes a web server, you should declare it as your application's web process.
For example, the Procfile for a Python Django web app might include the following process type:
web: gunicorn -b 0.0.0.0:$PORT blog.wsgi
No process types besides web have special properties.
For many simple applications, a single web process type can suffice. For more complex applications, and to adhere to the recommended approach of more explicitly declaring your application’s required runtime processes, you may wish to define additional process types. For example, Python applications are supplied with an additional process type of this sort:
As mentioned in the previous section, complex apps may require different processes to be executed, and this can be done through the Procfile file, as shown below:
web: gunicorn -b 0.0.0.0:$PORT blog.wsgi worker1: python app1.py worker2: python app2.py update: python app-update.py
As mentioned before, only the web: process has special properties, and its name must be kept in the Procfile at all times when you are using one as part of your application deployment command.
Other processes that may be added can have different names. However, process names in the file must be unique.
For each process in the Procfile, Ketch creates a separate deployment that will result in a similar architecture to the one presented below:
You can reference environment variables in the command inside the Procfile as well by following the example below:
web: ./manage.py runserver 0.0.0.0:$PORT
Creating Environment Variables
Before using environment variables inside your Procfile during the application deployment process, you should first make sure the variables are already created and available to your application, which can be done both at application creation time or before application deployment.
For more information on managing environment variables, please visit this link
Updated 9 months ago