Skip to content

Commit 0dece64

Browse files
Some more stuff
1 parent 0eb05c5 commit 0dece64

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
#######
22
Manager
33
#######
4+
5+
The Manager is the driving force behind Director. It is a Django application
6+
that runs the actual `director site <https://director.tjhsst.edu>`_.
7+
For the most part, we'll only talk about the ``sites`` app in this section.
8+
9+
The most useful models we use are the :class:`.Site` model and the :class:`.Operation` model.
10+
The :class:`.Operation` model is just a representation of a task that needs to be done (ex: updating
11+
an Nginx configuration).
12+
13+
.. tip::
14+
15+
Given a :class:`.Operation`, you'll often see :func:`auto_run_operation_wrapper` being used to execute
16+
the operation. This context manager returns a :class:`.OperationWrapper`.
17+
The most important method you'll see used is :meth:`~.OperationWrapper.add_action`, which effectively schedules
18+
a callback (see the overloads for how to use it as a method vs as a decorator).
19+
Then, after running all of the callbacks, if all callbacks succeed, it will delete the original operation.
20+
21+
22+
Communication with other parts
23+
------------------------------
24+
Let's talk a little bit about how the Manager communicates with other parts.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
############
22
Orchestrator
33
############
4+
5+
The orchestrator is responsible for the
6+
high-level Nginx commands, as well as managing the docker containers.
7+
8+
If you have not yet read :doc:`manager`, you should probably read that first.
9+
10+
Nginx
11+
-----
12+
The Orchestrator manages it's own Nginx config to deal
13+
with incoming requests at ``site-{site-id}.conf``. This config is
14+
separate from the router's Nginx config, so we'll spend a moment talking
15+
about some features and how the Orchestrator works with it.
16+
17+
If the website type is ``static``, the Nginx config is where the files in ``/public``
18+
are served from:
19+
20+
.. code-block:: nginx
21+
22+
server {
23+
# ...
24+
25+
location / {
26+
root site_dir/public;
27+
}
28+
}
29+
30+
Note that Jinja is used for turning a template into a functional Nginx configuration.
31+
The data to populate the template is NOT from the orchestrator, but rather from
32+
a request from the Manager to the Orchestrator. Importantly, the Manager can send a
33+
post request with the field ``custom_nginx_config`` to inject any other nginx configuration
34+
needed.
35+
36+
When updating the Nginx config, the orchestrator first moves the old configuration into
37+
``site-{site-id}.conf.bak``. Only if that succeeds will it write the new configuration.

docs/source/guides/architecture/overview.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ Director is made out of four main parts.
103103
- The Shell runs an ssh server using ``AsyncSSH`` to communicate with the Manager.
104104

105105

106+
If you want to learn about each part in more detail, check out
107+
the following articles (in the correct order):
108+
109+
- :doc:`manager`
110+
- :doc:`orchestrator`
111+
- :doc:`router_shell`
112+
113+
106114
Manager
107115
~~~~~~~
108116

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
11
################
22
Router and Shell
33
################
4+
5+
If you haven't read :doc:`orchestrator` and :doc:`manager`,
6+
it's recommended to read those first to get an idea of how
7+
the router especially fits into the big picture.
8+
9+
Router
10+
------
11+
Each part of Director serves a purpose: the manager for the frontend,
12+
the orchestrator for editing configs, and so on. The job of the
13+
router is much like an internet router: it is supposed to forward
14+
Nginx requests to the orchestrator. Additionally, it also
15+
is responsible for generating *Let's Encrypt* certificates if
16+
requested by the manager.
17+
18+
To be more specific, each :class:`.Site` has a custom nginx config stored in a separate
19+
file (``site-{side-id}.conf`` at the time of writing). The router is responsible for managing
20+
this file, making sure it is valid, and reloading nginx as needed.
21+
This may be a little bit confusing because the Orchestrator also has a per-site Nginx config.
22+
However, this nginx config is NOT the same: it's used to reroute requests to the orchestrator
23+
app servers, and are stored in a different location then the orchestrators ``site-{site-id}.conf``.
24+
25+

0 commit comments

Comments
 (0)