Switch swap threshold default to absolute 3048 MB and disable percent threshold by default

This commit is contained in:
Andrew Emelyaneko
2026-10-31 20:14:18 +03:00
parent 8cccc2612d
commit bdf7b9686d
6 changed files with 30 additions and 6 deletions
+13
View File
@@ -110,6 +110,19 @@ sudo ufw allow from <ip-клиента-opencode> to any port 8731 proto tcp
sudo systemctl restart ollama
```
## Порог swap
По умолчанию агент сравнивает общий объём **используемого** swap с конкретным размером:
`swap_threshold_mb = 3048`. Процентный режим выключен (`swap_threshold_percent = null`).
Чтобы оставить прежнее процентное поведение, задайте, например:
```json
{
"swap_threshold_percent": 25,
"swap_threshold_mb": null
}
```
## Проверка агента на сервере
```sh
+2 -1
View File
@@ -4,7 +4,8 @@
"token": "replace-with-strong-token",
"allow_insecure": false,
"poll_interval_seconds": 60,
"swap_threshold_percent": 25,
"swap_threshold_percent": null,
"swap_threshold_mb": 3048,
"cooldown_seconds": 600,
"max_restarts_per_hour": 2,
"restart_force_after_seconds": 300,
+4 -2
View File
@@ -30,7 +30,8 @@ case "${OS}" in
"token": "replace-with-strong-token",
"allow_insecure": false,
"poll_interval_seconds": 60,
"swap_threshold_percent": 25,
"swap_threshold_percent": null,
"swap_threshold_mb": 3048,
"cooldown_seconds": 600,
"max_restarts_per_hour": 2,
"restart_force_after_seconds": 300,
@@ -94,7 +95,8 @@ PLIST
"token": "replace-with-strong-token",
"allow_insecure": false,
"poll_interval_seconds": 60,
"swap_threshold_percent": 25,
"swap_threshold_percent": null,
"swap_threshold_mb": 3048,
"cooldown_seconds": 600,
"max_restarts_per_hour": 2,
"restart_force_after_seconds": 300,
+2 -2
View File
@@ -18,8 +18,8 @@ DEFAULT_CONFIG = {
"token": None,
"allow_insecure": False,
"poll_interval_seconds": 60,
"swap_threshold_percent": 25,
"swap_threshold_mb": None,
"swap_threshold_percent": None,
"swap_threshold_mb": 3048.0,
"cooldown_seconds": 600,
"max_restarts_per_hour": 2,
"restart_force_after_seconds": 300,
+1
View File
@@ -20,6 +20,7 @@ def make_config(tmp_path):
"state_file": str(tmp_path / "state.json"),
"launch_agent_plist": str(tmp_path / "com.ollama.serve.plist"),
"poll_interval_seconds": 60,
"swap_threshold_mb": 30,
}
)
+8 -1
View File
@@ -67,4 +67,11 @@ def test_count_recent():
def test_load_config_missing_file(tmp_path):
config = c.load_config(str(tmp_path / "config.json"))
assert config["port"] == 8731
assert config["swap_threshold_percent"] == 25
assert config["swap_threshold_percent"] is None
assert config["swap_threshold_mb"] == 3048.0
def test_threshold_absolute_default():
config = c.merge_config({})
assert c.threshold_exceeded(config, c.SwapStats(2048, 596.38, 1451.62)) is False
assert c.threshold_exceeded(config, c.SwapStats(2048, 3048, 0)) is True