fix(watchdog,priority,dns_failover,providers): reduce CPU/memory footprint on low-end routers (1.3.20)

- priority.uc: replace 1s tight sleep loop with dynamic interval based on group config (5s default)
- dns_failover.uc: replace 1s sleep with min(active_interval, recovery_interval)
- watchdog.uc: cap pending_smart_domains at 500 entries, add 300s TTL expiry
- event_controller.uc: batch is_dns_working nslookup calls into single shell process
- byedpi/runtime.uc: add crash-loop backoff (up to 6x base delay after 5 rapid crashes)
- nfqueue/runtime.uc: same crash-loop backoff for nfqws supervisors
This commit is contained in:
Dushnilin
2026-09-04 19:44:20 +03:00
parent 69b6cf18ec
commit 529db5fc6c
6 changed files with 63 additions and 14 deletions
@@ -167,9 +167,10 @@ function sing_box_in_proc() {
}
function is_dns_working() {
return command_success_from_args([ "nslookup", "-timeout=2", "yandex.ru", "127.0.0.1" ]) ||
command_success_from_args([ "nslookup", "-timeout=2", "connectivitycheck.gstatic.com", "127.0.0.1" ]) ||
command_success_from_args([ "nslookup", "-timeout=2", "google.com", "127.0.0.1" ]);
return command_success_from_args([ "sh", "-c",
"nslookup -timeout=2 yandex.ru 127.0.0.1 >/dev/null 2>&1 || " +
"nslookup -timeout=2 connectivitycheck.gstatic.com 127.0.0.1 >/dev/null 2>&1 || " +
"nslookup -timeout=2 google.com 127.0.0.1 >/dev/null 2>&1" ]);
}
function check_tachyon_cli_running() {
@@ -388,6 +388,8 @@ let last_restart_time = 0;
let last_reload_time = 0;
let pending_smart_domains = {};
let smart_detect_last_run = 0;
const PENDING_SMART_DOMAINS_MAX = 500;
const PENDING_SMART_DOMAINS_TTL = 300;
let last_fast_check = 0;
let last_normal_check = 0;
let last_slow_check = 0;
@@ -1417,6 +1419,12 @@ function smart_detect_process_pending() {
let now = time();
if (now - smart_detect_last_run < 30) return;
let stale_cutoff = now - PENDING_SMART_DOMAINS_TTL;
for (let dom in keys(pending_smart_domains)) {
if (pending_smart_domains[dom] < stale_cutoff)
delete pending_smart_domains[dom];
}
let domain_list = keys(pending_smart_domains);
if (length(domain_list) == 0) return;
smart_detect_last_run = now;
@@ -1546,6 +1554,7 @@ function heal_oom(ev) {
// smart_detect_process_pending(): probing inside the log handler would block
// the event loop on curl for every failing connection.
function collect_smart_detect_candidate(ev) {
if (length(pending_smart_domains) >= PENDING_SMART_DOMAINS_MAX) return;
pending_smart_domains[ev.payload.domain] = time();
}