<commit_before>unit states
===========

pending
----------

Is when the unit is waiting to be provisioned by the tsuru provisioner.

bulding
-----------

Is while the unit is provisioned, it's occurs while a deploy.

error
------

Is when the an error occurs caused by the application code.

down
-------

Is when an error occurs caused by tsuru internal problems.

unreachable
-----------------

Is when the app process is up, but it is not bound to the right host
("0.0.0.0") and/or right port ($PORT). If your process is a worker it's state
will be `unreachable`.

started
---------

Is when the app process is up binded  in the right host ("0.0.0.0") and right
port ($PORT).<commit_msg>docs: updated unit states.<commit_after>Unit states
===========

Unit status a the way to know what is happening with an unit. You can use the
`tsuru app-info -a <appname>` to see the unit status:

.. highlight:: bash

::

    $ tsuru app-info -a tsuru-dashboard
    Application: tsuru-dashboard
    Repository: git@localhost:tsuru-dashboard.git
    Platform: python
    ...
    Units: 1
    +------------+---------+
    | Unit       | State   |
    +------------+---------+
    | 9cf863c2c1 | started |
    +------------+---------+

The unit state flow is:

.. highlight:: bash

::

    +----------+                           start          +---------+
    | building |                   +---------------------+| stopped |
    +----------+                   |                      +---------+
          ^                        |                           ^
          |                        |                           |
     deploy unit                   |                         stop
          |                        |                           |
          +                        v       RegisterUnit        +
     +---------+  app unit   +----------+  SetUnitStatus  +---------+
     | created | +---------> | starting | +-------------> | started |
     +---------+             +----------+                 +---------+
                                   +                         ^ +
                                   |                         | |
                             SetUnitStatus                   | |
                                   |                         | |
                                   v                         | |
                               +-------+     SetUnitStatus   | |
                               | error | +-------------------+ |
                               +-------+ <---------------------+

* `created`: is the initial status of an unit.
* `building`: is the status for units being provisioned by the provisioner, like in the deployment.
* `error`: is the status for units that failed to start, because of an application error.
* `starting`: is set when the container is started in docker.
* `started`: is for cases where the unit is up and running.
* `stopped`: is for cases where the unit has been stopped.
{'fraction_non_alphanumeric': 0.1815415821501014, 'fraction_numerical': 0.005070993914807302, 'mean_word_length': 0.8980115458627326, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3712989', 'n_tokens_mistral': 717, 'n_tokens_neox': 667, 'n_words': 244}