📝 — Improve documentation (fix #11)

Extra:
- put psycopg2-binary in standard dependencies
This commit is contained in:
Luc Didry 2024-04-03 17:19:27 +02:00
parent 8fd45302d2
commit 2064d94fb9
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
11 changed files with 104 additions and 33 deletions

View file

@ -28,7 +28,7 @@ pylint: venv ## Runs pylint on the code
venv/bin/pylint argos venv/bin/pylint argos
pylint-alembic: venv ## Runs pylint on alembic migration files pylint-alembic: venv ## Runs pylint on alembic migration files
venv/bin/pylint --disable invalid-name,no-member alembic/versions/*.py venv/bin/pylint --disable invalid-name,no-member alembic/versions/*.py
lint: djlint pylint lint: djlint pylint pylint-alembic ruff
help: help:
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) @python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

View file

@ -10,6 +10,8 @@ To access the API, you need to pass an authentication token in the `Authorizatio
"Authorization": "Bearer " + token "Authorization": "Bearer " + token
``` ```
See the [CLI documentation](cli.md#server-generate-token-command) to generate tokens.
## Endpoints ## Endpoints
You can also have access to the Swagger API documentation at `https://<argos-url>/docs`, and the ReDoc documentation at `https://<argos-url>/redoc`. You can also have access to the Swagger API documentation at `https://<argos-url>/docs`, and the ReDoc documentation at `https://<argos-url>/redoc`.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

BIN
docs/dashboard.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

View file

@ -0,0 +1,11 @@
# Installing for development
To install all what you need to develop on Argos, do:
```bash
git clone https://framagit.org/framasoft/framaspace/argos.git
cd argos
make develop
```
It will create a virtualenv and install all the needed dependencies in it.

21
docs/developer/tests.md Normal file
View file

@ -0,0 +1,21 @@
# Tests and linting
## Tests
To launch the tests suite:
```bash
make tests
```
## Linting
There is 4 lintings checks:
- `make djlint` will check the linting of the HTML templates
- `make pylint` will check the linting of Argos source code
- `make pylint-alembic` will check the linting of Alembics migrations files
- `make ruff` will check the linting of all files
You can launch all of them with:
```bash
make lint
```

BIN
docs/domains.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View file

@ -10,33 +10,20 @@ Test how your websites respond to external checks, get notified when something g
- A **Website** allows to navigate the results of the checks. - A **Website** allows to navigate the results of the checks.
- **HTTP API**: An HTTP API is exposed to get the results of the checks. - **HTTP API**: An HTTP API is exposed to get the results of the checks.
![Dashboard](dashboard.jpg)
![Argos web interface](capture.png) ![Domains list](domains.jpg)
## Installation
```{code-block} bash
pip install argos-monitoring
argos server start
argos agent http://localhost:8000 "<auth-token>"
```
```{literalinclude} ../config-example.yaml
---
caption: config.yaml
---
```
## Next ## Next
::::{grid} 2 ::::{grid} 2
:::{grid-item-card} Getting started :::{grid-item-card} Installation
:link: installation/getting-started.html :link: installation/getting-started.html
The best way to get started with argos. The best way to get started with argos.
::: :::
:::{grid-item-card} Developper docs :::{grid-item-card} Developper docs
:link: developer/overview.html :link: developer/overview.html
You want to know more about the internals ?. You want to know more about the internals ?
::: :::
:::: ::::
@ -69,9 +56,11 @@ checks
:caption: Developer docs :caption: Developer docs
:hidden: :hidden:
developer/overview developer/overview
developer/dependencies
developer/new-check developer/new-check
developer/models developer/models
developer/migrations developer/migrations
developer/tests
developer/projects developer/projects
changelog changelog
``` ```

View file

@ -15,17 +15,53 @@ source venv/bin/activate
pip install -e . pip install -e .
``` ```
<!--
## Install with pip
```bash
pip install argos-monitoring
```
You may want to install Argos in a virtualenv:
```bash
python3 -m venv venv
source venv/bin/activate
pip install argos-monitoring
```
## Install from sources
Once you got the source locally, create a virtualenv and install the dependencies:
```bash
python3 -m venv venv
source venv/bin/activate
pip install -e .
```
-->
## Configure ## Configure
### Configure the checks
The quickest way to get started is to copy the `config-example.yaml` file and edit it: The quickest way to get started is to copy the `config-example.yaml` file and edit it:
```bash ```bash
cp config-example.yaml config.yaml cp config-example.yaml config.yaml
``` ```
<!--
The quickest way to get started is to get the `config-example.yaml` file from our repository and edit it:
```bash
wget https://framagit.org/framasoft/framaspace/argos/-/raw/main/config-example.yaml -O config.yaml
```
-->
You can read more about the configuration in the [configuration section](../configuration.md). You can read more about the configuration in the [configuration section](../configuration.md).
## Starting the server ### Configure the server
Environment variables are used to configure the server. You can also put them in an `.env` file: Environment variables are used to configure the server. You can also put them in an `.env` file:
@ -37,6 +73,8 @@ caption: .env
Please note that the only supported database engines are SQLite for development and PostgreSQL for production. Please note that the only supported database engines are SQLite for development and PostgreSQL for production.
## Starting the server
Then you can start the server: Then you can start the server:
```bash ```bash
@ -45,12 +83,30 @@ argos server start
The server reads the `yaml` file at startup, and populates the tasks queue with the checks defined in the configuration. The server reads the `yaml` file at startup, and populates the tasks queue with the checks defined in the configuration.
## Generating a token
The agent needs an authentication token to be able to communicate with the server.
You can generate an authentication token with the following command:
```bash
argos server generate-token
```
Add the token in the configuration file, in the following setting:
```yaml
service:
secrets:
- "auth-token"
```
## Running the agent ## Running the agent
You can run the agent on the same machine as the server, or on a different machine. The only requirement is that the agent can reach the server. You can run the agent on the same machine as the server, or on a different machine.
The only requirement is that the agent can reach the server.
```bash ```bash
argos agent http://localhost:8000 "<auth-token>" argos agent http://localhost:8000 "auth-token"
``` ```
## Cleaning the database ## Cleaning the database
@ -61,6 +117,6 @@ Here is a crontab example, which will clean the db each hour:
```bash ```bash
# Run the cleaning tasks every hour (at minute 7) # Run the cleaning tasks every hour (at minute 7)
# Keeps 10 results per task, and locks the tasks for 1 hour # Keeps 10 results per task, and remove tasks locks older than 1 hour
7 * * * * argos server cleandb --max-results 10 --max-lock-seconds 3600 7 * * * * argos server cleandb --max-results 10 --max-lock-seconds 3600
``` ```

View file

@ -1,10 +1,4 @@
# Use with PostgreSQL # Install and configure PostgreSQL
If you intend to use argos with Postgresql, which is recommended for production, you can install it with the following commands:
```bash
pip install -e ".[postgres]"
```
Here are a few steps for you to install PostgreSQL on your system: Here are a few steps for you to install PostgreSQL on your system:

View file

@ -20,8 +20,10 @@ dependencies = [
"alembic>=1.13.0,<1.14", "alembic>=1.13.0,<1.14",
"click>=8.1,<9", "click>=8.1,<9",
"fastapi>=0.103,<0.104", "fastapi>=0.103,<0.104",
"gunicorn>=21.2,<22",
"httpx>=0.25,<1", "httpx>=0.25,<1",
"Jinja2>=3.0,<4", "Jinja2>=3.0,<4",
"psycopg2-binary>=2.9,<3",
"pydantic[email]>=2.4,<3", "pydantic[email]>=2.4,<3",
"pydantic-settings>=2.0,<3", "pydantic-settings>=2.0,<3",
"pyyaml>=6.0,<7", "pyyaml>=6.0,<7",
@ -30,7 +32,6 @@ dependencies = [
"sqlalchemy-utils>=0.41,<1", "sqlalchemy-utils>=0.41,<1",
"tenacity>=8.2,<9", "tenacity>=8.2,<9",
"uvicorn>=0.23,<1", "uvicorn>=0.23,<1",
"gunicorn>=21.2,<22",
] ]
[project.optional-dependencies] [project.optional-dependencies]
@ -47,9 +48,6 @@ dev = [
"ruff==0.1.5,<1", "ruff==0.1.5,<1",
"sphinx-autobuild", "sphinx-autobuild",
] ]
postgres = [
"psycopg2-binary>=2.9,<3",
]
docs = [ docs = [
"cogapp", "cogapp",
"myst-parser>=2.0,<3", "myst-parser>=2.0,<3",