When deploying applications directly from the source code, Procfile describes the components that are required to run an application in Shipa.
The Procfile specifies the commands that are executed by the app upon startup time. 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.
The Procfile must live in the root directory of the application. It will not function if placed anywhere else.
Procfiles are used by Cloud Native Buildpacks to build docker image with start up scripts for each processes.
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 Shipa 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.
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, Shipa creates a separate deployment that will result in a similar architecture to the one presented below:
Users can reference environment variables in the command as well by following the example below:
web: ./manage.py runserver 0.0.0.0:$PORT
Updated 9 months ago