🔀 Merge remote-tracking branch 'origin/fix-36' into develop

This commit is contained in:
Luc Didry 2024-06-17 16:18:13 +02:00
commit 2380c9be7d
No known key found for this signature in database
GPG key ID: EA868E12D0257E3C
8 changed files with 49 additions and 29 deletions

1
.gitignore vendored
View file

@ -5,5 +5,6 @@ venv
.env
public
*.swp
argos-config.yaml
config.yaml
dist

View file

@ -8,6 +8,7 @@
- ✨ — Add command to generate example configuration (fix #38)
- 📝 — Improve documentation
- ✨ — Add command to warn if its been long since last viewing an agent (fix #49)
- 💥 — Change default config file path to argos-config.yaml (fix #36)
## 0.1.1

View file

@ -34,14 +34,22 @@ def coroutine(f):
def validate_config_access(ctx, param, value):
path = Path(value)
if path.is_file() and os.access(path, os.R_OK):
return value
for file in set(value, "argos-config.yaml", "/etc/argos/config.yaml"):
path = Path(file)
if path.is_file():
raise click.BadParameter(f"the file {value} is not readabale.")
if path.is_file() and os.access(path, os.R_OK):
return file
raise click.BadParameter(f"the file {value} does not exists or is not reachable.")
if value == "argos-config.yaml":
raise click.BadParameter(
f"the file {value} does not exists or is not reachable, "
"nor does /etc/argos/config.yaml."
)
raise click.BadParameter(
f"the file {value} does not exists or is not reachable, "
"nor does argos-config.yaml or /etc/argos/config.yaml."
)
@click.group()
@ -102,9 +110,10 @@ def agent(server_url, auth, max_tasks, wait_time, log_level):
@click.option("--port", default=8000, type=int, help="Port to bind")
@click.option(
"--config",
default="config.yaml",
default="argos-config.yaml",
help="Path of the configuration file. "
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead. "
"Default value: argos-config.yaml and /etc/argos/config.yaml as fallback.",
envvar="ARGOS_YAML_FILE",
callback=validate_config_access,
)
@ -150,9 +159,10 @@ def validate_max_results(ctx, param, value):
)
@click.option(
"--config",
default="config.yaml",
default="argos-config.yaml",
help="Path of the configuration file. "
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead. "
"Default value: argos-config.yaml and /etc/argos/config.yaml as fallback.",
envvar="ARGOS_YAML_FILE",
callback=validate_config_access,
)
@ -216,9 +226,10 @@ async def watch_agents(time_without_agent, config):
@server.command(short_help="Load or reload tasks configuration")
@click.option(
"--config",
default="config.yaml",
default="argos-config.yaml",
help="Path of the configuration file. "
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead. "
"Default value: argos-config.yaml and /etc/argos/config.yaml as fallback.",
envvar="ARGOS_YAML_FILE",
callback=validate_config_access,
)
@ -247,9 +258,10 @@ async def reload_config(config):
@server.command()
@click.option(
"--config",
default="config.yaml",
default="argos-config.yaml",
help="Path of the configuration file. "
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead.",
"If ARGOS_YAML_FILE environment variable is set, its value will be used instead. "
"Default value: argos-config.yaml and /etc/argos/config.yaml as fallback.",
envvar="ARGOS_YAML_FILE",
callback=validate_config_access,
)

View file

@ -23,11 +23,10 @@ class Settings(BaseSettings):
class DevSettings(Settings):
"""Settings for dev environment.
Uses config.yaml as config file.
Uses argos-config.yaml as config file.
Uses a SQLite database."""
app_env: str = "dev"
yaml_file: str = "config.yaml"
db_pool_size: Optional[int] = None
db_max_overflow: Optional[int] = None
database_url: str = "sqlite:////tmp/argos.db"

View file

@ -13,7 +13,7 @@ These checks are the most basic ones. They simply check that the response from t
```{code-block} yaml
---
caption: config.yaml
caption: argos-config.yaml
---
- domain: "https://example.org"
paths:
@ -30,7 +30,7 @@ caption: config.yaml
```{code-block} yaml
---
caption: config.yaml
caption: argos-config.yaml
---
ssl:
thresholds:

View file

@ -107,7 +107,9 @@ Options:
--host TEXT Host to bind
--port INTEGER Port to bind
--config TEXT Path of the configuration file. If ARGOS_YAML_FILE environment
variable is set, its value will be used instead.
variable is set, its value will be used instead. Default
value: argos-config.yaml and /etc/argos/config.yaml as
fallback.
--reload Enable hot reloading
--help Show this message and exit.
```
@ -129,7 +131,8 @@ Usage: argos server migrate [OPTIONS]
Options:
--config TEXT Path of the configuration file. If ARGOS_YAML_FILE environment
variable is set, its value will be used instead.
variable is set, its value will be used instead. Default value:
argos-config.yaml and /etc/argos/config.yaml as fallback.
--help Show this message and exit.
```
@ -158,7 +161,8 @@ Options:
checks have a timeout value of 60 seconds)
--config TEXT Path of the configuration file. If ARGOS_YAML_FILE
environment variable is set, its value will be
used instead.
used instead. Default value: argos-config.yaml and
/etc/argos/config.yaml as fallback.
--help Show this message and exit.
```
@ -208,7 +212,8 @@ Usage: argos server reload-config [OPTIONS]
Options:
--config TEXT Path of the configuration file. If ARGOS_YAML_FILE environment
variable is set, its value will be used instead.
variable is set, its value will be used instead. Default value:
argos-config.yaml and /etc/argos/config.yaml as fallback.
--help Show this message and exit.
```

View file

@ -21,6 +21,8 @@ Here are the environment variables you can define to configure how the service w
The path to the yaml configuration file, defining the checks.
If you do not provide the environment variable, Argos will try to read `argos-config.yaml` in the current directory, then `/etc/config/argos.yaml`.
#### ARGOS_DATABASE_URL
The database url, as defined [in SQLAlchemy docs](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls).
@ -28,7 +30,7 @@ The database url, as defined [in SQLAlchemy docs](https://docs.sqlalchemy.org/en
For instance, to connect to a postgres database on localhost with user, pass and dbname "argos":
```
ARGOS_DATABASE_URL = "postgresql://argos:argos@localhost/argos"
ARGOS_DATABASE_URL="postgresql://argos:argos@localhost/argos"
```
#### DB_POOL_SIZE
@ -37,8 +39,8 @@ ARGOS_DATABASE_URL = "postgresql://argos:argos@localhost/argos"
You configure the size of the database pool of connection, and the max overflow (until when new connections are accepted ?) These are documented [in the SQLAlchemy docs in greater details](https://docs.sqlalchemy.org/en/20/core/pooling.html#sqlalchemy.pool.QueuePool.params.pool_size)
```bash
DB_POOL_SIZE = 10
DB_MAX_OVERFLOW = 20
DB_POOL_SIZE=10
DB_MAX_OVERFLOW=20
```
## Argos "checks" configuration
@ -50,7 +52,7 @@ Here is a simple configuration file:
```{literalinclude} ../conf/config-example.yaml
---
caption: config.yaml
caption: argos-config.yaml
---
```

View file

@ -42,7 +42,7 @@ pip install -e .
The quickest way to get started is to generate the configuration file from argos and edit it:
```bash
argos server generate-config > config.yaml
argos server generate-config > argos-config.yaml
```
You can read more about the configuration in the [configuration section](../configuration.md).