Switch swap threshold default to absolute 3048 MB and disable percent threshold by default
This commit is contained in:
@@ -110,6 +110,19 @@ sudo ufw allow from <ip-клиента-opencode> to any port 8731 proto tcp
|
|||||||
sudo systemctl restart ollama
|
sudo systemctl restart ollama
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Порог swap
|
||||||
|
|
||||||
|
По умолчанию агент сравнивает общий объём **используемого** swap с конкретным размером:
|
||||||
|
`swap_threshold_mb = 3048`. Процентный режим выключен (`swap_threshold_percent = null`).
|
||||||
|
|
||||||
|
Чтобы оставить прежнее процентное поведение, задайте, например:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"swap_threshold_percent": 25,
|
||||||
|
"swap_threshold_mb": null
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Проверка агента на сервере
|
## Проверка агента на сервере
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
|||||||
+2
-1
@@ -4,7 +4,8 @@
|
|||||||
"token": "replace-with-strong-token",
|
"token": "replace-with-strong-token",
|
||||||
"allow_insecure": false,
|
"allow_insecure": false,
|
||||||
"poll_interval_seconds": 60,
|
"poll_interval_seconds": 60,
|
||||||
"swap_threshold_percent": 25,
|
"swap_threshold_percent": null,
|
||||||
|
"swap_threshold_mb": 3048,
|
||||||
"cooldown_seconds": 600,
|
"cooldown_seconds": 600,
|
||||||
"max_restarts_per_hour": 2,
|
"max_restarts_per_hour": 2,
|
||||||
"restart_force_after_seconds": 300,
|
"restart_force_after_seconds": 300,
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ case "${OS}" in
|
|||||||
"token": "replace-with-strong-token",
|
"token": "replace-with-strong-token",
|
||||||
"allow_insecure": false,
|
"allow_insecure": false,
|
||||||
"poll_interval_seconds": 60,
|
"poll_interval_seconds": 60,
|
||||||
"swap_threshold_percent": 25,
|
"swap_threshold_percent": null,
|
||||||
|
"swap_threshold_mb": 3048,
|
||||||
"cooldown_seconds": 600,
|
"cooldown_seconds": 600,
|
||||||
"max_restarts_per_hour": 2,
|
"max_restarts_per_hour": 2,
|
||||||
"restart_force_after_seconds": 300,
|
"restart_force_after_seconds": 300,
|
||||||
@@ -94,7 +95,8 @@ PLIST
|
|||||||
"token": "replace-with-strong-token",
|
"token": "replace-with-strong-token",
|
||||||
"allow_insecure": false,
|
"allow_insecure": false,
|
||||||
"poll_interval_seconds": 60,
|
"poll_interval_seconds": 60,
|
||||||
"swap_threshold_percent": 25,
|
"swap_threshold_percent": null,
|
||||||
|
"swap_threshold_mb": 3048,
|
||||||
"cooldown_seconds": 600,
|
"cooldown_seconds": 600,
|
||||||
"max_restarts_per_hour": 2,
|
"max_restarts_per_hour": 2,
|
||||||
"restart_force_after_seconds": 300,
|
"restart_force_after_seconds": 300,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ DEFAULT_CONFIG = {
|
|||||||
"token": None,
|
"token": None,
|
||||||
"allow_insecure": False,
|
"allow_insecure": False,
|
||||||
"poll_interval_seconds": 60,
|
"poll_interval_seconds": 60,
|
||||||
"swap_threshold_percent": 25,
|
"swap_threshold_percent": None,
|
||||||
"swap_threshold_mb": None,
|
"swap_threshold_mb": 3048.0,
|
||||||
"cooldown_seconds": 600,
|
"cooldown_seconds": 600,
|
||||||
"max_restarts_per_hour": 2,
|
"max_restarts_per_hour": 2,
|
||||||
"restart_force_after_seconds": 300,
|
"restart_force_after_seconds": 300,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ def make_config(tmp_path):
|
|||||||
"state_file": str(tmp_path / "state.json"),
|
"state_file": str(tmp_path / "state.json"),
|
||||||
"launch_agent_plist": str(tmp_path / "com.ollama.serve.plist"),
|
"launch_agent_plist": str(tmp_path / "com.ollama.serve.plist"),
|
||||||
"poll_interval_seconds": 60,
|
"poll_interval_seconds": 60,
|
||||||
|
"swap_threshold_mb": 30,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -67,4 +67,11 @@ def test_count_recent():
|
|||||||
def test_load_config_missing_file(tmp_path):
|
def test_load_config_missing_file(tmp_path):
|
||||||
config = c.load_config(str(tmp_path / "config.json"))
|
config = c.load_config(str(tmp_path / "config.json"))
|
||||||
assert config["port"] == 8731
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user