<commit_before>HireFire
========

This is a Python package for HireFire_ -- The Heroku_ Process Manager:

.. epigraph::

  HireFire has the ability to automatically scale your web and worker
  dynos up and down when necessary. When new jobs are queued in to your
  application's worker queue [..], HireFire will spin up new worker
  dynos to process these jobs. When the queue is empty, HireFire will
  shut down the worker dynos again so you're not paying for idle
  workers.

  HireFire also has the ability to scale your web dynos. When your web
  application experiences heavy traffic during certain times of the day,
  or if you've been featured somewhere, chances are your application's
  backlog might grow to a point that your web application will run
  dramatically slow, or even worse, it might result in a timeout. In
  order to prevent this, HireFire will automatically scale your web
  dynos up when traffic increases to ensure that your application runs
  fast at all times. When traffic decreases, HireFire will spin down
  your web dynos again.

  -- from the HireFire_ frontpage

It supports the following Python queuing systems as backends:

* Celery_
* HotQueue_
* Huey_
* Queues_
* RQ_

Feel free to `contribute other backends`_ if you're using a different
queuing system.

.. _HireFire: http://hirefire.io/
.. _Heroku: http://www.heroku.com/
.. _Celery: http://celeryproject.com/
.. _HotQueue: http://richardhenry.github.com/hotqueue/
.. _Huey: http://huey.readthedocs.org/
.. _Queues: http://queues.googlecode.com/
.. _RQ: http://python-rq.org/
.. _`contribute other backends`: https://github.com/jezdez/hirefire/

.. note::

  This package is currently (02/16/2013) targetting the HireFire
  **beta** version ("`manager.hirefire.io`_") **NOT** the old product
  ("`monitor.hirefireapp.com`_").

  See the `beta support forum`_ to `get started`_ with this improved
  version.

  .. _`beta support forum`: http://hirefireapp.tenderapp.com/kb/beta/credit-card-support
  .. _`get started`: http://support.hirefire.io/kb/beta/getting-started-migrating-adding-applications
  .. _`manager.hirefire.io`: http://manager.hirefire.io/
  .. _`monitor.hirefireapp.com`: https://monitor.hirefireapp.com/

Installation
------------

Install the HireFire package with your favorite installer, e.g.:

.. code-block:: bash

  pip install HireFire

Sign up for the `HireFire (beta)`_ and set the ``HIREFIRE_TOKEN``
environment variable with the `Heroku CLI`_ as provided on the
specific HireFire `application page`_, e.g.:

.. code-block:: bash

  heroku config:set HIREFIRE_TOKEN=f<PASSWORD>c<PASSWORD>48daf187caa6<PASSWORD>

Now follow the quickstart guide below and don't forget to tweak the
options in the `HireFire management system`_.

.. _`Heroku CLI`: https://devcenter.heroku.com/articles/heroku-command
.. _`HireFire (beta)`: https://manager.hirefire.io/
.. _`HireFire management system`: https://manager.hirefire.io/

Configuration
-------------

The ``hirefire`` Python package currently supports only one framework:
Django. Implementations for other frameworks are planned but haven't been
worked on: Flask_, Pyramid_ (PasteDeploy), WSGI_ middleware, ..

Feel free to `contribute one`_ if you can't wait.

.. _`contribute one`: https://github.com/jezdez/hirefire/
.. _flask: http://flask.pocoo.org/
.. _Pyramid: http://www.pylonsproject.org/
.. _WSGI: http://www.python.org/dev/peps/pep-3333/

Django
^^^^^^

Setting up HireFire support for Django is easy:

#. Add ``'hirefire.contrib.django.middleware.HireFireMiddleware' to your
   ``MIDDLEWARE_CLASSES`` setting::

     MIDDLEWARE_CLASSES = [
         'hirefire.contrib.django.middleware.HireFireMiddleware',
         # ...
     ]

   Make sure it's the first item in the list/tuple.

#. Define as many ``hirefire.procs.Proc`` subclasses as you want HireFire
   to monitor. Have a look at your ``Procfile`` file to do it.

   For example here is a ``Procfile`` which uses RQ_ for the worker proccess::

     web: python manage.py runserver
     worker: DJANGO_SETTINGS_MODULE=mysite.settings rqworker high default low

   Define a ``RQProc`` subclass somewhere in your Django project,
   e.g. ``mysite/procs.py``, with the appropriate attributes (``name``
   and ``queues``)::<commit_msg>Fixed minor typo in README.<commit_after>HireFire
========

This is a Python package for HireFire_ -- The Heroku_ Process Manager:

.. epigraph::

  HireFire has the ability to automatically scale your web and worker
  dynos up and down when necessary. When new jobs are queued in to your
  application's worker queue [..], HireFire will spin up new worker
  dynos to process these jobs. When the queue is empty, HireFire will
  shut down the worker dynos again so you're not paying for idle
  workers.

  HireFire also has the ability to scale your web dynos. When your web
  application experiences heavy traffic during certain times of the day,
  or if you've been featured somewhere, chances are your application's
  backlog might grow to a point that your web application will run
  dramatically slow, or even worse, it might result in a timeout. In
  order to prevent this, HireFire will automatically scale your web
  dynos up when traffic increases to ensure that your application runs
  fast at all times. When traffic decreases, HireFire will spin down
  your web dynos again.

  -- from the HireFire_ frontpage

It supports the following Python queuing systems as backends:

* Celery_
* HotQueue_
* Huey_
* Queues_
* RQ_

Feel free to `contribute other backends`_ if you're using a different
queuing system.

.. _HireFire: http://hirefire.io/
.. _Heroku: http://www.heroku.com/
.. _Celery: http://celeryproject.com/
.. _HotQueue: http://richardhenry.github.com/hotqueue/
.. _Huey: http://huey.readthedocs.org/
.. _Queues: http://queues.googlecode.com/
.. _RQ: http://python-rq.org/
.. _`contribute other backends`: https://github.com/jezdez/hirefire/

.. note::

  This package is currently (02/16/2013) targetting the HireFire
  **beta** version ("`manager.hirefire.io`_") **NOT** the old product
  ("`monitor.hirefireapp.com`_").

  See the `beta support forum`_ to `get started`_ with this improved
  version.

  .. _`beta support forum`: http://hirefireapp.tenderapp.com/kb/beta/credit-card-support
  .. _`get started`: http://support.hirefire.io/kb/beta/getting-started-migrating-adding-applications
  .. _`manager.hirefire.io`: http://manager.hirefire.io/
  .. _`monitor.hirefireapp.com`: https://monitor.hirefireapp.com/

Installation
------------

Install the HireFire package with your favorite installer, e.g.:

.. code-block:: bash

  pip install HireFire

Sign up for the `HireFire (beta)`_ and set the ``HIREFIRE_TOKEN``
environment variable with the `Heroku CLI`_ as provided on the
specific HireFire `application page`_, e.g.:

.. code-block:: bash

  heroku config:set HIREFIRE_TOKEN=f69f0c0ddebe041248daf187caa6abb3e5d943ca

Now follow the quickstart guide below and don't forget to tweak the
options in the `HireFire management system`_.

.. _`Heroku CLI`: https://devcenter.heroku.com/articles/heroku-command
.. _`HireFire (beta)`: https://manager.hirefire.io/
.. _`HireFire management system`: https://manager.hirefire.io/

Configuration
-------------

The ``hirefire`` Python package currently supports only one framework:
Django. Implementations for other frameworks are planned but haven't been
worked on: Flask_, Pyramid_ (PasteDeploy), WSGI_ middleware, ..

Feel free to `contribute one`_ if you can't wait.

.. _`contribute one`: https://github.com/jezdez/hirefire/
.. _flask: http://flask.pocoo.org/
.. _Pyramid: http://www.pylonsproject.org/
.. _WSGI: http://www.python.org/dev/peps/pep-3333/

Django
^^^^^^

Setting up HireFire support for Django is easy:

#. Add ``'hirefire.contrib.django.middleware.HireFireMiddleware'`` to your
   ``MIDDLEWARE_CLASSES`` setting::

     MIDDLEWARE_CLASSES = [
         'hirefire.contrib.django.middleware.HireFireMiddleware',
         # ...
     ]

   Make sure it's the first item in the list/tuple.

#. Define as many ``hirefire.procs.Proc`` subclasses as you want HireFire
   to monitor. Have a look at your ``Procfile`` file to do it.

   For example here is a ``Procfile`` which uses RQ_ for the worker proccess::

     web: python manage.py runserver
     worker: DJANGO_SETTINGS_MODULE=mysite.settings rqworker high default low

   Define a ``RQProc`` subclass somewhere in your Django project,
   e.g. ``mysite/procs.py``, with the appropriate attributes (``name``
   and ``queues``)::
{'fraction_non_alphanumeric': 0.11221857410881801, 'fraction_numerical': 0.00574577861163227, 'mean_word_length': 3.7488864142538976, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 12, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1712303', 'n_tokens_mistral': 2772, 'n_tokens_neox': 2642, 'n_words': 923}