|
| 1 | +:title: Process Types and the Procfile |
| 2 | +:description: First steps for using the 12 factor process model with Deis. |
| 3 | + |
| 4 | +.. _process-types: |
| 5 | + |
| 6 | +Process Types and the Procfile |
| 7 | +============================== |
| 8 | + |
| 9 | +A Procfile is a mechanism for declaring what commands are run by your application’s containers on |
| 10 | +the Deis platform. It follows the `process model`_. You can use a Procfile to declare various |
| 11 | +process types, such as multiple types of workers, a singleton process like a clock, or a consumer |
| 12 | +of the Twitter streaming API. |
| 13 | + |
| 14 | +Process Types as Templates |
| 15 | +-------------------------- |
| 16 | + |
| 17 | +A Procfile is a text file named ``Procfile`` placed in the root of your application that lists the |
| 18 | +process types in an application. Each process type is a declaration of a command that is executed |
| 19 | +when a container of that process type is started. |
| 20 | + |
| 21 | +All the language and frameworks using :ref:`Heroku's Buildpacks <using-buildpacks>` declare a |
| 22 | +``web`` process type, which starts the application server. Rails 3 has the following process type: |
| 23 | + |
| 24 | +.. code-block:: console |
| 25 | +
|
| 26 | + web: bundle exec rails server -p $PORT |
| 27 | +
|
| 28 | +All applications using :ref:`Dockerfile deployments <using-dockerfiles>` have an implied ``cmd`` |
| 29 | +process type, which spawns the default process of a Docker image: |
| 30 | + |
| 31 | +.. code-block:: console |
| 32 | +
|
| 33 | + $ cat Dockerfile |
| 34 | + FROM centos:latest |
| 35 | + COPY . /app |
| 36 | + WORKDIR /app |
| 37 | + CMD python -m SimpleHTTPServer 5000 |
| 38 | + EXPOSE 5000 |
| 39 | +
|
| 40 | +For applications using :ref:`Docker image deployments <using-docker-images>`, a ``cmd`` process |
| 41 | +type is also implied and spawns the default process of the image. |
| 42 | + |
| 43 | +Declaring Process Types |
| 44 | +----------------------- |
| 45 | + |
| 46 | +Process types are declared via a file named ``Procfile``, placed in the root of your app. Its |
| 47 | +format is one process type per line, with each line containing: |
| 48 | + |
| 49 | +.. code-block:: console |
| 50 | +
|
| 51 | + <process type>: <command> |
| 52 | +
|
| 53 | +The syntax is defined as: |
| 54 | + |
| 55 | +``<process type>`` – an alphanumeric string, is a name for your command, such as web, worker, urgentworker, clock, etc. |
| 56 | + |
| 57 | +``<command>`` – a command line to launch the process, such as ``rake jobs:work``. |
| 58 | + |
| 59 | +.. note:: |
| 60 | + |
| 61 | + The web and cmd process types are special as they’re the only process types that will receive |
| 62 | + HTTP traffic from Deis’s routers. Other process types can be named arbitrarily. |
| 63 | + |
| 64 | +Deploying to Deis |
| 65 | +----------------- |
| 66 | + |
| 67 | +A ``Procfile`` is not necessary to deploy most languages supported by Deis. The platform |
| 68 | +automatically detects the language and supplies a default ``web`` process type to boot the server. |
| 69 | + |
| 70 | +Creating an explicit Procfile is recommended for greater control and flexibility over your app. |
| 71 | + |
| 72 | +For Deis to use your Procfile, add the Procfile to the root of your application, then push to Deis: |
| 73 | + |
| 74 | +.. code-block:: console |
| 75 | +
|
| 76 | + $ git add . |
| 77 | + $ git commit -m "Procfile" |
| 78 | + $ git push deis master |
| 79 | + ... |
| 80 | + -----> Procfile declares process types: web, worker |
| 81 | + Compiled slug size is 10.4MB |
| 82 | +
|
| 83 | + Launching... done, v2 |
| 84 | +
|
| 85 | + -----> unisex-huntress deployed to Deis |
| 86 | + http://unisex-huntress.example.com |
| 87 | +
|
| 88 | +For docker image deployments, a Procfile in the current directory or via the ``--procfile`` option |
| 89 | +flag will be used as the default process types for the application. |
| 90 | + |
| 91 | +.. _`process model`: https://devcenter.heroku.com/articles/process-model |
0 commit comments