Files
kapow/docs/source/concepts/request_life_cycle.rst
pancho horrillo 1e63f3c104 feat: Control API uses automatic cross-pinning mTLS (Closes #119)
. kapow server generates on startup a pair of certificates
that will use to secure communications to its control server.
It will communicate the server and client certificates as well
as the client private key to the init programs it launches,
via environment variables.

. kapow server now understands a new flag --control-reachable-addr
which accepts either a IP address or a DNS name, that can be used
to ensure that the generated server certificate will be appropiate
in case the control server must be accessed from something other
than localhost.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2021-03-12 17:24:17 +01:00

62 lines
1.5 KiB
ReStructuredText

Request Life Cycle
==================
This section describes the sequence of events happening for each request
answered by the :ref:`http-user-interface`.
.. image:: ../_static/request_life_cycle.png
1. request
----------
The user makes a request to the :ref:`http-user-interface`.
- The request is matched against the route table.
- :program:`kapow` provides a `HANDLER_ID` to identify this request and don't
mix it with other requests that could be running concurrently.
2. spawn
--------
:program:`kapow` spawns the executable specified as entrypoint in the matching
route.
The default entrypoint is :command:`/bin/sh`; let's focus on this workflow.
The spawned entrypoint is run with the following variables added to its
environment:
- :envvar:`KAPOW_HANDLER_ID`: Containing the `HANDLER_ID`
- :envvar:`KAPOW_DATA_URL`: With the URL of the :ref:`http-data-interface`
- :envvar:`KAPOW_CONTROL_URL`: With the URL of the :ref:`https-control-interface`
3. ``kapow set /response/body banana``
--------------------------------------
During the lifetime of the shell, the :ref:`request and response resources
<resource-tree>` are available via these commands:
- ``kapow get /request/...``
- ``kapow set /response/...``
These commands use the aforementioned environment variables to read data
from the user request and to write the response. They accept data either as
arguments or from `stdin`.
4. exit
-------
The shell dies. Long live the shell!
5. response
-----------
:program:`kapow` finalizes the original request. Enjoy your banana now.