Slim scheduler, add maintenance module

- Introduced a new `maintenance` module to handle data retention, log rotation, and nightly email tasks.
- Updated the `scheduler` to utilize the `MaintenanceRunner` for executing maintenance tasks, improving code organization and clarity.
- Enhanced documentation to reflect changes in logging configuration and data retention processes.
- Adjusted tests to accommodate the refactored scheduler methods and ensure proper functionality.
This commit is contained in:
agessaman
2026-03-19 19:40:33 -07:00
parent 219de10afd
commit 07a2db4ede
9 changed files with 920 additions and 519 deletions
+8
View File
@@ -20,6 +20,14 @@ The main sections include:
| `[Weather]` | Units and settings shared by `wx` / `gwx` and Weather Service |
| `[Logging]` | Log file path and level |
### Logging and log rotation
- **Startup (config.ini):** Under `[Logging]`, `log_file`, `log_max_bytes`, and `log_backup_count` are read when the bot starts. They control the initial `RotatingFileHandler` for the bot log file (see `config.ini.example`).
- **Live changes (web viewer):** The Config tab can store **`maint.log_max_bytes`** and **`maint.log_backup_count`** in the database (`bot_metadata`). The schedulers maintenance loop applies those values to the existing rotating file handler **without restarting** the bot—**but only after** you save rotation settings from the web UI (which writes the metadata keys). Editing `config.ini` alone does not update `bot_metadata`, so hot-apply will not see a change until you save from the viewer (or set the keys another way).
If you rely on config-file-only workflows, restart the bot after changing `[Logging]` rotation options.
## Channels section
`[Channels]` controls where the bot responds:
+1 -1
View File
@@ -34,7 +34,7 @@ Shorter retention (e.g. 23 days for `packet_stream`) is enough for the web vi
## How cleanup runs
1. The **scheduler** (in the main bot process) runs a single data-retention task once every 24 hours.
1. The **scheduler** (in the main bot process) runs a single data-retention task on a **24-hour interval** after startup (the first run is not immediate on boot; it aligns with the nightly maintenance email cadence).
2. That task:
- Cleans **packet_stream** (via web viewer integration when enabled).
- Cleans **purging_log**, **daily_stats**, **unique_advert_packets**, and **observed_paths** (repeater manager).