Implement balance monitoring and notification for Selectel API integration

- Added support for balance tracking using `SELECTEL_API_TOKEN` in the configuration.
- Introduced new balance notification logic in the local watchdog, alerting users on balance changes based on defined thresholds.
- Updated documentation to include instructions for setting up balance notifications and the required environment variables.
- Enhanced the `ready` and `session` modules to initialize balance state and handle notifications during GPU operations.
- Refactored the CLI and related components to support the new balance monitoring features, ensuring a seamless user experience.
This commit is contained in:
Leonid Pershin
2026-08-21 06:52:51 +03:00
parent 7ed6a99df2
commit 09b7c36f3b
14 changed files with 759 additions and 12 deletions
+13 -2
View File
@@ -231,8 +231,9 @@ Application credential для idle-killer CLI создаёт на `up` (узко
1. Nova `ACTIVE`
2. TCP 22 / SSH
3. HTTP `http://127.0.0.1:7801` **на VM** (через SSH)
4. Backend Idle → toast (если `NOTIFY_READY`) + access-card
3. На VM: HTTP сервисов стека (SwarmUI `:7801` / Ollama `:11434` / llama.cpp `:8080`) — `verify_stack_on_vm`
4. Backend Idle (если SwarmUI) → toast (если `NOTIFY_READY`)
5. Туннель + проверка **localhost** тех же сервисов → access-card
Локальный порт UI: **17801** (на VM по-прежнему 7801 на loopback).
@@ -241,3 +242,13 @@ Application credential для idle-killer CLI создаёт на `up` (узко
## Windows / notify
`NOTIFY_READY`: toast + системный звук, когда backend Idle. Если toast недоступен — только звук и лог, без падения CLI.
### Баланс Selectel (шаг 200 ₽)
Нужны:
1. `SELECTEL_API_TOKEN` в `.env`**статический ключ панели** (`X-Token`), не OpenStack password ([баланс API](https://docs.selectel.ru/api/balance/)).
2. `gpu-rent watchdog install` — тот же локальный тикер, что и аварийный stop.
На `up` запоминается baseline баланса. Каждый tick watchdog: если с `up` ушло ещё ~200 ₽ (`BALANCE_NOTIFY_STEP_RUB`) — toast «Списано ~N ₽…». Пополнение сбрасывает baseline. Опционально `BALANCE_NOTIFY_LOW_RUB=300` — разовое «баланс низкий».