forked from WLJSTeam/wljs-notebook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster.wls
More file actions
executable file
·73 lines (50 loc) · 1.86 KB
/
master.wls
File metadata and controls
executable file
·73 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(*import shared libraries*)
Import/@FileNames["*.wls", "shared"];
(*load core modules*)
Import["modules/db.wls"];
Import["modules/misc.wls"];
Import["modules/notifications.wls"];
Import["modules/svhost.wls"];
Import["modules/watcher.wls"];
(*notebooks support*)
Import["modules/converter.wls"];
Import["modules/cells.wls"];
Import["modules/notebook.wls"];
(*load libs from the services*)
Import/@FileNames["lib.wls", "services", 2];
(*check*)
If[FileExistsQ["running.lock"],
console["log", ">>crashed before"];
PushNotification["kitchen", "Wolfram Engine crashed. We are sorry 😢"];
];
(*clear pages*)
Put["running.lock"];
(*dunno if it helps here*)
$HistoryLength = 0;
temp = <||>;
settings["processes"] = <||>;
settings["memory"] = {Round[MemoryInUse[]/1024,1]/1024//N};
settings["cpu"] = 0;
settings["notifications"] = <||>;
(*debug stream*)
$Messages = {OpenWrite[Method -> "Toast"]};
(*async tasks*)
CronTasks["ping pong"] = SessionSubmit[
ScheduledTask[WebSocketBroadcast[server, Pong[]],
Quantity[5, "Seconds"]]];
CronTasks["hide notifications"] = SessionSubmit[
ScheduledTask[
(settings["notifications"][#]["hide"] = True) &/@ (Select[settings["notifications"]//Keys, (settings["notifications", #, "date"] < (Now - settings["notifications", #, "duration"]))&]),
Quantity[2, "Minutes"]]];
CronTasks["remove notifications"] = SessionSubmit[
ScheduledTask[
(settings["notifications"][#] = .;)&/@ (Select[settings["notifications"]//Keys, (settings["notifications"][#]["date"] < (Now - Quantity[1, "Days"]))&]),
Quantity[6, "Hours"]]];
CronTasks["backup"] = SessionSubmit[
ScheduledTask[CBackup,
Quantity[60, "Minutes"]]];
CronTasks["timestamp"] = SessionSubmit[
ScheduledTask[console["log", "<*Now*>"]; console["memory stat"];,
Quantity[20, "Minutes"]]];
CronTasks["forecast"] = SessionSubmit[
ScheduledTask[Forecast, "Daily"]];