!7 sS url = "http://localhost/1010504/raw/number-of-threads"; static double timeout = 60.0, delay = 30.0; static int consecutiveFailsThreshold = 2; static int consecutiveFailsThresholdWhenLoading = 20; sbool loading; static int consecutiveFails; p { printWithDateAndTimeInThisThread(); repeat with sleep delay { bool ok = false; loading = false; pcall { long time = sysNow(); S s = loadPageWithTimeout(url, timeout); if (startsWith(s, "LOADING")) loading = true; if (isInteger(s)) { ok = true; consecutiveFails = 0; print("Server OK - " + n2(parseLong(s), "thread", "threads") + ", " + (sysNow()-time) + " ms"); } } if (!ok) { ++consecutiveFails; print("Server fail #" + consecutiveFails + "/" + actualThreshold() + (loading ? " (loading)" : "")); pcall { serverFailActivity(); } } } } static int actualThreshold() { ret loading ? consecutiveFailsThresholdWhenLoading : consecutiveFailsThreshold; } svoid serverFailActivity { if (consecutiveFails == actualThreshold()) { print("RESTARTING ELEU."); hardKillProgram(#1002017); run(#1002710); } }