Warning: session_start(): open(/var/lib/php/sessions/sess_iaaacc04jrqa7gtsnrem080esa, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
cmodule FrontendUnloader > DynPrintLogAndEnabled {
switchable double timeout = 60.0; // in seconds after last activity
switchable double checkInterval = 10.0;
switchable bool actuallyUnload;
transient bool firstCheck = true;
start {
dm_doEvery(1.0, checkInterval, r check);
}
void check enter {
if (!enabled || dm_isBooting()) ret;
// stayLoaded -> module ID. also has a null key!
new MultiMap mm;
for (O mod : vmBus_queryAll chatBotFrontend()) {
Bool b = cast dm_call(mod, 'shouldStayLoaded, timeout);
mm.put(b, dm_moduleID(mod));
}
if (empty(mm)) ret;
int nPlus = l(mm.get(true));
int nMinus = l(mm.get(false));
int nIndifferent = l(mm.get(null));
print("Results for timeout " + timeout + "s: " + nPlus + " should stay loaded, "
+ nMinus + " can be unloaded, " + nIndifferent + " indifferent");
if (actuallyUnload)
if (firstCheck)
firstCheck = false;
else
unloadModules(mm.get(false));
}
void unloadModules(LS modules) {
if (empty(modules)) ret;
print("Unloading " + nModules(modules));
for (S mod : modules) {
print(" Unloading " + mod);
dm_pcall(mod, 'deleteYourself);
}
}
afterVisualize {
addComponentInFront(buttons, dm_checkBox actuallyUnload());
}
}