github.com/greenboxal/deis@v1.12.1/docs/using_deis/process-types.rst (about)

     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 specified by
    89  ``deis pull --procfile`` will define the default process types for the application.
    90  
    91  Use ``deis scale web=3`` to increase ``web`` processes to 3, for example. Scaling a
    92  process type directly changes the number of :ref:`Containers <container>`
    93  running that process.
    94  
    95  Web vs Cmd Process Types
    96  ------------------------
    97  
    98  When deploying to Deis using a Heroku Buildpack, Deis boots the ``web`` process type to boot the
    99  application server. When you deploy an application that has a Dockerfile or uses :ref:`Docker
   100  images <using-docker-images>`, Deis boots the ``cmd`` process type. Both act similarly in that they
   101  are exposed to the router as web applications. However, The ``cmd`` process type is special because
   102  it is equivalent to running the :ref:`container` without any additional arguments. Every other
   103  process type is equivalent to running the relevant command that is provided in the Procfile.
   104  
   105  When migrating from Heroku Buildpacks to a Docker-based deployment, Deis will not convert ``web``
   106  process types to ``cmd``. To do this, you'll have to manually scale down the old process type and
   107  scale the new process type up.
   108  
   109  
   110  .. _`process model`: https://devcenter.heroku.com/articles/process-model