Skip to content

Commit

Permalink
chore(doc): Update async docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alithethird committed Dec 17, 2024
1 parent ec5db1e commit d517d98
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 30 deletions.
32 changes: 16 additions & 16 deletions docs/reference/extensions/django-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ server metrics.
and ``[email protected]`` bases.

The Django extension supports both synchronous and asynchronous
Gunicorn workers. If you want asynchronous workers, you have to add
the ``gevent`` package to the ``requirements.txt`` file.
Read more
:ref:`Using asynchronous Gunicorn workers <django-async-gunicorn-workers>`.
Gunicorn workers.

Project requirements
====================
Expand All @@ -35,6 +32,12 @@ There are 2 requirements to be able to use the ``django-framework`` extension:
``./<Rock name with - replaced by _>/<Rock name with - replaced by _>/manage.py``
relative to the ``rockcraft.yaml`` file.

For the project to make use of asynchronous Gunicorn workers:

- The ``requirements.txt`` file must include ``gevent`` as a dependency.

Read more
:ref:`Gunicorn worker selection <django-gunicorn-worker-selection>`.

``parts`` > ``django-framework/dependencies:`` > ``stage-packages``
===================================================================
Expand All @@ -50,26 +53,23 @@ application. In the following example we use it to specify ``libpq-dev``:
# list required packages or slices for your Django application below.
- libpq-dev
.. _django-async-gunicorn-workers:
.. _django-gunicorn-worker-selection:

Using asynchronous Gunicorn workers
===================================
Gunicorn worker selection
=========================

If you want to use asynchronous workers, you have to add the ``gevent`` package
to the ``requirements.txt`` file. Rockcraft automatically detects this and
updates the Pebble plan to use the asynchronous workers. If you have ``gevent``
installed in your rock but decided to use ``sync`` workers instead you can do
so by using the ``--args`` parameter of ``docker run``:
If the project has gevent as a dependency, Rockcraft automatically updates the
pebble plan to spawn asynchronous Gunicorn workers.

When the project instead needs synchronous workers, you can override the worker
type by adding ``--args django sync`` to the Docker command that launches the
rock:

.. code-block:: bash
docker run --name django-container -d -p 8000:8000 django-image:1.0 \
--args django sync
.. note::
The Django extension is compatible with the ``bare``, ``[email protected]`` and
``[email protected]`` bases.

Useful links
============

Expand Down
32 changes: 18 additions & 14 deletions docs/reference/extensions/flask-framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ server metrics.
and ``[email protected]`` bases.

The Flask extension supports both synchronous and asynchronous
Gunicorn workers. If you want asynchronous workers, you have to add
``gevent`` package to the ``requirements.txt`` file.
Read more
:ref:`Using asynchronous Gunicorn workers <flask-async-gunicorn-workers>`.
Gunicorn workers.

Project requirements
====================
Expand All @@ -31,7 +28,14 @@ There are 2 requirements to be able to use the ``flask-framework`` extension:
``Flask`` declared as a dependency
2. The project must include a WSGI app with the path ``app:app``. This means
there must be an ``app.py`` file at the root of the project with the name
of the Flask object is set to ``app``
of the Flask object is set to ``app``.

For the project to make use of asynchronous Gunicorn workers:

- The ``requirements.txt`` file must include ``gevent`` as a dependency.

Read more
:ref:`Gunicorn worker selection <flask-gunicorn-worker-selection>`.

``parts`` > ``flask-framework/dependencies`` > ``stage-packages``
=================================================================
Expand All @@ -47,17 +51,17 @@ application. In the following example we use it to specify ``libpq-dev``:
# list required packages or slices for your flask app below.
- libpq-dev
.. _flask-async-gunicorn-workers:
.. _flask-gunicorn-worker-selection:

Gunicorn worker selection
=========================

Using asynchronous Gunicorn workers
===================================
If the project has gevent as a dependency, Rockcraft automatically updates the
pebble plan to spawn asynchronous Gunicorn workers.

If you want to use asynchronous workers, you have to add ``gevent`` package to
the ``requirements.txt`` file. Rockcraft automatically detects this and updates
the pebble plan to use the asynchronous workers. If you have ``gevent``
installed in your rock but decided to use ``sync`` workers instead you can use
the ``--args`` parameter of ``docker run`` to use ``sync`` workers instead of
the default ``gevent``:
When the project instead needs synchronous workers, you can override the worker
type by adding ``--args flask sync`` to the Docker command that launches the
rock:

.. code-block:: bash
Expand Down

0 comments on commit d517d98

Please sign in to comment.