Warning: session_start(): open(/var/lib/php/sessions/sess_tj63kgo0rbnpu84cv2i0cqai99, 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
srecord noeq G22AutoStarter(G22Utils g22utils) > MetaWithChangeListeners {
settableWithVar volatile bool enabled;
settable double initialDelay = 2;
settableWithVar int nScriptsRun;
new Flag started;
new Flag waited;
new Flag done;
L scripts = syncL();
record noeq AutoStartScript(G22LeftArrowScript script) > RunResultWithTimestamps {
run {
LASCompileResult cr = script.compileForAutoRun();
if (cr == null) cr = script.compileSaved();
reMutable cr;
run(-> {
G22AutoStarter.this.change();
if (cr == null) fail("Script is not saved: " + script);
var parsed = cr.parsedScriptMandatory();
ret parsed!;
});
nScriptsRun(nScriptsRun+1);
}
}
void init() {
scripts.clear();
var scripts = conceptsWhere(g22utils.concepts, G22LeftArrowScript, runOnProjectOpen := true);
for (script : scripts)
this.scripts.add(new AutoStartScript(script));
change();
}
void start {
if (enabled && started.raise()) thread {
change();
temp g22utils.backgroundProcessesUI.tempAdd("Auto-Start Scripts", );
sleepSeconds(initialDelay);
waited.raise();
change();
for (script : scripts) pcall {
if (!enabled) break;
script.run();
}
done.raise();
change();
}
}
void cancel { setEnabled(false); }
S status() {
ret !enabled ? "Cancelled"
: done! ? "Done"
: waited! ? "Started"
: started! ? "Pre-start wait (" + initialDelay + "s)"
: "Not started";
}
S stats() {
ret status() + ". Scripts run: " + nScriptsRun() + "/" + l(scripts);
}
}