fix(stability): optimize Go memory tiers, prevent nftables degradation deadlock, harden NTP & process supervision
- singbox/runtime.uc: add dynamic 4-tier GOMEMLIMIT and GOGC limits based on RAM, enforce /etc/tachyon/mem_scale, and install managed init script across all binary variants - service/event_controller.uc: guard probe_nftables() with recovery_bypass and native_internet_restored checks to prevent 5-minute network drop deadlock - service/watchdog.uc: reduce Telegram worker heartbeat timeout from 900s to 300s and add nslookup fallback to Zero-RTT prefetcher - diagnostics/runtime.uc & service/lifecycle.uc: use direct-IP NTP pool to eliminate circular DNS/TLS deadlocks, and step clock forward on cold boot if RTC desynced - service/failover.uc & diagnostics/runtime.uc: flush conntrack states on proxy group switch so client connections immediately migrate
This commit is contained in:
@@ -642,6 +642,8 @@ function controller(bus, opts) {
|
||||
|
||||
// ── Probe: nftables table and QoS marks ───────────────────────────────────
|
||||
function probe_nftables() {
|
||||
if (setting("recovery_bypass", "0") == "1") return;
|
||||
if (fs.stat("/var/run/tachyon/native_internet_restored") != null) return;
|
||||
if (is_list_update_running()) return;
|
||||
if (is_reload_in_progress()) return;
|
||||
|
||||
@@ -666,6 +668,7 @@ function controller(bus, opts) {
|
||||
// ── Probe: TPROXY port liveness ───────────────────────────────────────────
|
||||
function probe_tproxy() {
|
||||
if (setting("recovery_bypass", "0") == "1") return;
|
||||
if (fs.stat("/var/run/tachyon/native_internet_restored") != null) return;
|
||||
if (is_reload_in_progress()) return;
|
||||
|
||||
let pid = get_sing_box_pid();
|
||||
|
||||
@@ -121,6 +121,7 @@ function switch_group(section_name, outbound_name) {
|
||||
log_message("runtime switch failed: " + out, "warn");
|
||||
return false;
|
||||
}
|
||||
command_status("conntrack -F >/dev/null 2>&1 || true");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -835,6 +835,11 @@ function start_impl() {
|
||||
if (wd_status != 0)
|
||||
log_message("Watchdog start-runtime failed (status " + as_string(wd_status) + ")", "warn");
|
||||
|
||||
if (time() < 1704067200) {
|
||||
log_message("System clock is in the past (RTC desync); performing quick NTP synchronization...", "warn");
|
||||
command_status("ntpd -q -p 194.190.168.1 -p 216.239.35.0 -p 162.159.200.1 >/dev/null 2>&1 || true");
|
||||
}
|
||||
|
||||
let status = start_main();
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
||||
@@ -349,7 +349,7 @@ function run_zero_rtt_prefetching() {
|
||||
// that followed it attached to a null command in this shell instead
|
||||
// of to the backgrounded loop. Backgrounding is now the wrapper's
|
||||
// job, so the loop gets the redirections it was always meant to have.
|
||||
let batch_cmd = "for d in " + join(" ", batch) + "; do dig @127.0.0.1 \"$d\" A >/dev/null 2>&1; done";
|
||||
let batch_cmd = "for d in " + join(" ", batch) + "; do dig @127.0.0.1 \"$d\" A >/dev/null 2>&1 || nslookup \"$d\" 127.0.0.1 >/dev/null 2>&1; done";
|
||||
system(common.background_command(batch_cmd));
|
||||
batch = [];
|
||||
}
|
||||
@@ -1976,7 +1976,7 @@ function check_telegram_worker() {
|
||||
}
|
||||
|
||||
let age = time() - int(heartbeat);
|
||||
if (age <= 900)
|
||||
if (age <= 300)
|
||||
return;
|
||||
|
||||
let pid = trim(fs.readfile(TELEGRAM_PID_FILE) || "");
|
||||
|
||||
Reference in New Issue
Block a user