Download Jar. Uses 5404K of libraries. Click here for Pure Java version (15617L/100K).
!7 sbool smartBotToo = false; sS url = "http://localhost:8080/1010504/raw/number-of-threads"; sS mainURL = null; //"http://localhost:8080"; sS smartBotURL = "http://localhost:4678/number-of-threads"; static double timeout = 60.0, delay = 30.0; static int consecutiveFailsThreshold = /*2*/ 10; // times delay static int consecutiveFailsThresholdWhenLoading = 20; // not used static int consecutiveFails; static volatile S status; sbool playMode; p { bot("New Eleu Watch Dog."); if (cic(args, "playMode")) set playMode; if (smartBotToo) thread "Smart Bot Loop" { smartBotLoop(); } printWithDateAndTimeInThisThread(); repeat with sleep delay { bool ok = false, loading = false; pcall { long time = sysNow(); /*S mainData = loadPageWithTimeout(mainURL, timeout/2); if (!startsWith(mainData, "<") || swic(mainData, "ERROR")) { print("Error! " + mainData); } else {*/ S s = loadPageWithTimeout(url, timeout); if (startsWith(s, "LOADING")) loading = true; // TODO: loading is now code 500 if (isInteger(s)) { ok = true; consecutiveFails = 0; print(status = "Server OK - " + n2(parseLong(s), "thread", "threads") + ", " + (sysNow()-time) + " ms"); } //} } if (!ok) { ++consecutiveFails; print(status = "Server fail #" + consecutiveFails + " of " + actualThreshold(loading) + (loading ? " (loading)" : "")); pcall { serverFailActivity(loading); } } } } static int actualThreshold(bool loading) { ret loading ? consecutiveFailsThresholdWhenLoading : consecutiveFailsThreshold; } svoid serverFailActivity(bool loading) { if (consecutiveFails == actualThreshold(loading)) { consecutiveFails = 0; if (playMode) ret with print("WOULD RESTART ELEU."); print("RESTARTING ELEU."); hardKillProgram(#1013896); S eleuOptions = loadTextFileTrim(javaxDataDir("eleu.options")); directNohupJavax(joinNemptiesWithSpace(eleuOptions, str(psI(#1013896)))); } } answer { if "status" ret status; } svoid smartBotLoop { int consecutiveFails = 0; S status = ""; printWithDateAndTimeInThisThread(); repeat with sleep delay { bool ok = false, loading = false; pcall { long time = sysNow(); S s = loadPageWithTimeout(smartBotURL, timeout); if (startsWith(s, "LOADING")) loading = true; if (isInteger(s)) { ok = true; consecutiveFails = 0; print(status = "Smart Bot OK - " + n2(parseLong(s), "thread", "threads") + ", " + (sysNow()-time) + " ms"); } } if (!ok) { ++consecutiveFails; print(status = "Smart Bot fail #" + consecutiveFails + " of " + actualThreshold(loading) + (loading ? " (loading)" : "")); pcall { if (smartBotFailActivity(consecutiveFails, loading)) consecutiveFails = 0; } } } } sbool smartBotFailActivity(int consecutiveFails, bool loading) { if (consecutiveFails >= actualThreshold(loading)) { print("RESTARTING SMART BOT."); hardKillProgram(#1010745); nohupJavaxHeadless(#1010745); true; } false; }
Began life as a copy of #1012699
download show line numbers debug dex old transpilations
Travelled to 20 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, djztyncnmsck, gwrvuhgaqvyk, hpgrupgrauku, irmadwmeruwu, ishqpsrjomds, iveijnkanddl, lpdgvwnxivlt, mqqgnosmbjvj, odhhsrjjbcgr, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, twycvekltchr, vouqrxazstgt
No comments. add comment
Snippet ID: | #1014075 |
Snippet name: | Watch Dog for New Eleu + Smart Bot (only run on server) [LIVE] |
Eternal ID of this version: | #1014075/30 |
Text MD5: | 7f9015694523229f818df3ae3243a610 |
Transpilation MD5: | 8bd01f6a40735567ff0c17f848c40397 |
Author: | stefan |
Category: | javax |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-30 14:53:41 |
Source code size: | 3253 bytes / 105 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 558 / 2448 |
Version history: | 29 change(s) |
Referenced in: | #1013896 - Eleutheria Main for butter.botcompany.de + Stefan's OS (LIVE) #1022823 - Eleutheria Main for butter.botcompany.de as Dyn Module [dev.] #1024026 - Eleutheria Main for butter.botcompany.de (backup without Stefan's OS) #1032545 - Watch Dog for Ada SC [dev.] #3000526 - Smart Bot's answer to: !fresh latestPrograms() |