clavarium 0.2.150-beta.1 → 0.2.151-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/clavarium-host +30 -0
- package/deploy/maintenance.html +5 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/api.mjs +2 -1
- package/server/conversations.mjs +14 -0
- package/server/events.mjs +1 -0
- package/server/gitpush.mjs +18 -2
- package/server/main.mjs +8 -3
- package/server/serverlogs.mjs +6 -0
- package/web/app.js +30 -17
- package/web/index.html +2 -1
package/deploy/clavarium-host
CHANGED
|
@@ -994,6 +994,36 @@ case "$AREA $VERB" in
|
|
|
994
994
|
if [ "$SAY" = "yes" ]; then echo "systemd-run --on-active=2 systemctl restart clavarium.service"; exit 0; fi
|
|
995
995
|
systemd-run --quiet --collect --unit="clavarium-restart-$(date +%s)" --on-active=2 /usr/bin/systemctl restart clavarium.service
|
|
996
996
|
exit 0 ;;
|
|
997
|
+
"server reboot")
|
|
998
|
+
# THE WHOLE SERVER STARTED AGAIN, asked from the page (Settings, This server), after a
|
|
999
|
+
# confirmation there: in five seconds, by systemd, so that the page is answered first.
|
|
1000
|
+
# Every machine stops with it (cleanly, by the VM manager) and starts again after.
|
|
1001
|
+
[ $# -eq 0 ] || usage
|
|
1002
|
+
if [ "$SAY" = "yes" ]; then echo "systemd-run --on-active=5 systemctl reboot"; exit 0; fi
|
|
1003
|
+
systemd-run --quiet --collect --unit="clavarium-reboot-$(date +%s)" --on-active=5 /usr/bin/systemctl reboot
|
|
1004
|
+
exit 0 ;;
|
|
1005
|
+
"server protect")
|
|
1006
|
+
# WHAT KEEPS THE SERVER IN HAND (04-11), at each start of the server: should memory run out,
|
|
1007
|
+
# the kernel stops a machine first, never this server, its front or ssh. Made so for the next
|
|
1008
|
+
# start of each (a drop-in) and at once for what runs (choom). No argument; done again is the same.
|
|
1009
|
+
[ $# -eq 0 ] || usage
|
|
1010
|
+
if [ "$SAY" = "yes" ]; then echo "OOMScoreAdjust=-900 for clavarium caddy dex oauth2-proxy ssh"; exit 0; fi
|
|
1011
|
+
changed=no
|
|
1012
|
+
for unit in clavarium caddy dex oauth2-proxy ssh; do
|
|
1013
|
+
systemctl cat "$unit.service" >/dev/null 2>&1 || continue
|
|
1014
|
+
dir="/etc/systemd/system/$unit.service.d"; file="$dir/clavarium-oom.conf"
|
|
1015
|
+
want='# Written by clavarium-host (server protect): stopped last should memory run out.
|
|
1016
|
+
[Service]
|
|
1017
|
+
OOMScoreAdjust=-900'
|
|
1018
|
+
if [ "$(cat "$file" 2>/dev/null)" != "$want" ]; then
|
|
1019
|
+
mkdir -p "$dir" && printf '%s\n' "$want" > "$file" && changed=yes
|
|
1020
|
+
fi
|
|
1021
|
+
pid=$(systemctl show -p MainPID --value "$unit.service" 2>/dev/null)
|
|
1022
|
+
[ -n "$pid" ] && [ "$pid" != 0 ] && choom -n -900 -p "$pid" >/dev/null 2>&1 || true
|
|
1023
|
+
done
|
|
1024
|
+
[ "$changed" = no ] || systemctl daemon-reload
|
|
1025
|
+
echo "protected"
|
|
1026
|
+
exit 0 ;;
|
|
997
1027
|
"server room")
|
|
998
1028
|
# WHAT THE SERVER HAS LEFT, for Settings (This server) and for the
|
|
999
1029
|
# reserve that creating, starting, waking or growing a machine must
|
package/deploy/maintenance.html
CHANGED
|
@@ -56,17 +56,20 @@ const VERSION = /^\d{1,4}\.\d{1,4}\.\d{1,6}(-[0-9A-Za-z.-]{1,40})?$/;
|
|
|
56
56
|
when the server still announces an update about to stop it. */
|
|
57
57
|
const next = ({ kind, startedAt, now, seenDown, answer }) => {
|
|
58
58
|
const up = !!answer && !answer.down && !answer.update && !(answer.status >= 502 && answer.status <= 504);
|
|
59
|
-
|
|
59
|
+
/* The whole server (reboot): five seconds before it stops, a minute of grace. */
|
|
60
|
+
const grace = kind === 'reboot' ? 4 * RESTART_GRACE_MS : kind === 'restart' ? RESTART_GRACE_MS : 0;
|
|
61
|
+
if (up && !(grace && !seenDown && now - startedAt < grace)) return 'back';
|
|
60
62
|
return now - startedAt > STUCK_MS ? 'stuck' : 'wait';
|
|
61
63
|
};
|
|
62
64
|
|
|
63
|
-
/* WHAT IT SAYS, from its address (?kind=update|back|restart&to=<version>): the edge serves
|
|
65
|
+
/* WHAT IT SAYS, from its address (?kind=update|back|restart|reboot&to=<version>): the edge serves
|
|
64
66
|
it at any address, with none of these: then it cannot know which. */
|
|
65
67
|
const title = (kind, to) => {
|
|
66
68
|
const v = VERSION.test(to ?? '') ? to : '';
|
|
67
69
|
if (kind === 'update') return v ? `Updating Clavarium to ${v}...` : 'Updating Clavarium...';
|
|
68
70
|
if (kind === 'back') return v ? `Going back to Clavarium ${v}...` : 'Going back to the previous Clavarium...';
|
|
69
71
|
if (kind === 'restart') return 'Restarting Clavarium...';
|
|
72
|
+
if (kind === 'reboot') return 'Restarting the server: every machine starts again in a few minutes...';
|
|
70
73
|
return 'Clavarium is being updated or restarted...';
|
|
71
74
|
};
|
|
72
75
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.151-beta.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.151-beta.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/api.mjs
CHANGED
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
* GET /api/history?of=server|<name>&span=1h|24h|7d the curves of memory, CPU and disk (and the reserve, for the server)
|
|
110
110
|
* GET /api/history/all?span=1h|24h|7d Settings, Usage: the server and every machine (asleep too) on one time axis,
|
|
111
111
|
* in GB and cores: {t, capacity, server, itself, machines: [{name, alloc, asleep, ...}]}
|
|
112
|
-
* GET /api/server/logs?source=&span= what the server's programs said POST /api/server/restart
|
|
112
|
+
* GET /api/server/logs?source=&span= what the server's programs said POST /api/server/restart POST /api/server/reboot (the whole server)
|
|
113
113
|
* GET /api/operators who may sign in POST /api/operators {email} -> {email, password}: shown once
|
|
114
114
|
* POST /api/operators/<email>/password -> {email, password} POST /api/operators/<email>/disable|enable|remove
|
|
115
115
|
* POST /api/conversations/<name>/secrets {secret, attached}
|
|
@@ -552,6 +552,7 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
552
552
|
if (reactSet && reacting) { const n = decodeURIComponent(reactSet[1]); if (!conversations.list().some((c) => c.name === n)) throw new Refusal(404, 'No such conversation.'); return send(200, reacting.set(n, body)), true; }
|
|
553
553
|
if (pathname === '/api/machines/move' && machinesMove) return send(202, await machinesMove.move(String(body.to ?? ''))), true;
|
|
554
554
|
if (pathname === '/api/server/restart' && serverLogs) return send(202, await serverLogs.restart()), true;
|
|
555
|
+
if (pathname === '/api/server/reboot' && serverLogs) return send(202, await serverLogs.reboot()), true;
|
|
555
556
|
if (pathname === '/api/machines/grow' && machinesMove) return send(200, await machinesMove.grow(String(body.mount ?? ''))), true;
|
|
556
557
|
if (pathname === '/api/machines/mount' && machinesMove) return send(200, await machinesMove.mount(String(body.path ?? ''))), true;
|
|
557
558
|
if (pathname === '/api/machines/prepare' && machinesMove) return send(200, await machinesMove.prepare(String(body.path ?? ''), body.typed)), true;
|
package/server/conversations.mjs
CHANGED
|
@@ -778,6 +778,20 @@ export class Conversations {
|
|
|
778
778
|
return { session: 'renewed' };
|
|
779
779
|
}
|
|
780
780
|
|
|
781
|
+
/* RESTARTS ONLY ITS TOOL (04-11), for a tool that asks to be restarted (to take up new tools): its
|
|
782
|
+
machine is not touched -- a whole-machine restart may not start again, and a tool has no need of
|
|
783
|
+
it. Its tmux is ended and the tool started again in its terminal (`ready`), taking up its last
|
|
784
|
+
session, as after any start. A machine that does not run is left as it is: its next opening starts
|
|
785
|
+
the tool anyway. Resolves with whether the tool was restarted. */
|
|
786
|
+
async restartTool(name) {
|
|
787
|
+
this.#busyCheck(name);
|
|
788
|
+
if ((await this.#vms.state(name).catch(() => undefined)) !== 'Running') return false;
|
|
789
|
+
this.drop(name);
|
|
790
|
+
await this.#vms.exec(name, ['tmux', '-L', SOCKET, 'kill-server'], { timeoutMs: 10_000 }).catch(() => {});
|
|
791
|
+
this.ready(name);
|
|
792
|
+
return true;
|
|
793
|
+
}
|
|
794
|
+
|
|
781
795
|
async #fixup(name, tool) {
|
|
782
796
|
for (const step of tool.fixups) {
|
|
783
797
|
const r = await this.#vms.exec(name, step.argv, { timeoutMs: 120_000 }).catch(() => ({ code: 1 }));
|
package/server/events.mjs
CHANGED
|
@@ -51,6 +51,7 @@ const SAID = [
|
|
|
51
51
|
[/^\/api\/updates\/back$/, 'update', (m, b) => `Going back to ${clip(b.version, 30)} asked`],
|
|
52
52
|
[/^\/api\/updates\/settings$/, 'update', (m, b) => `Updates set: ${['mode', 'channel', 'window'].filter((k) => b[k]).map((k) => `${k} ${clip(b[k], 20)}`).join(', ')}`],
|
|
53
53
|
[/^\/api\/server\/restart$/, 'server', () => 'This server restarted'],
|
|
54
|
+
[/^\/api\/server\/reboot$/, 'server', () => 'The whole server restarted'],
|
|
54
55
|
[/^\/api\/server\/reserve$/, 'server', (m, b) => `Reserve set${b.diskMb !== undefined ? `: disk ${b.diskMb} MB` : ''}${b.memoryMb !== undefined ? `, memory ${b.memoryMb} MB` : ''}`],
|
|
55
56
|
[/^\/api\/machines\/move$/, 'server', (m, b) => `All the machines moved to ${clip(b.to, 60)}`],
|
|
56
57
|
[/^\/api\/machines\/prepare$/, 'server', (m, b) => `Disk ${clip(b.path, 40)} erased and prepared for the machines`],
|
package/server/gitpush.mjs
CHANGED
|
@@ -71,6 +71,8 @@ export function escaped(text) {
|
|
|
71
71
|
|
|
72
72
|
export class GitReview {
|
|
73
73
|
#store; #vault; #resources; #local; #access; #runner; #now; #listeners = []; #waivers = () => ({});
|
|
74
|
+
/* The refresh of each repository on its way: { run, waitMs }, by name. */
|
|
75
|
+
#refreshing = new Map();
|
|
74
76
|
|
|
75
77
|
/* `localRemotes`: lets a remote be a directory of this machine. For tests only.
|
|
76
78
|
`runner`: the git runner (gitrunner.mjs); its reads go through the host program. */
|
|
@@ -204,8 +206,22 @@ export class GitReview {
|
|
|
204
206
|
The only writer of the reference. */
|
|
205
207
|
async refresh(name, { waitMs = SEND_WAIT_MS } = {}) {
|
|
206
208
|
const r = this.#repository(name);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
/* One on its way already, that waits at least as long as this one
|
|
210
|
+
would: its fetch is shared, not made again behind it. A page that
|
|
211
|
+
reviews several branches of a repository at once (To send) would
|
|
212
|
+
otherwise line up one fetch per branch behind the reference's lock,
|
|
213
|
+
and the last ones be refused as busy -- and drop out of the list. */
|
|
214
|
+
const going = this.#refreshing.get(r.name);
|
|
215
|
+
if (going && going.waitMs >= waitMs) return going.run;
|
|
216
|
+
const run = (async () => {
|
|
217
|
+
const release = await this.#runner.lock(this.#reference(r.name), waitMs);
|
|
218
|
+
try { return await this.#refreshLocked(r); } finally { release(); }
|
|
219
|
+
})();
|
|
220
|
+
const entry = { run, waitMs };
|
|
221
|
+
this.#refreshing.set(r.name, entry);
|
|
222
|
+
const done = () => { if (this.#refreshing.get(r.name) === entry) this.#refreshing.delete(r.name); };
|
|
223
|
+
run.then(done, done);
|
|
224
|
+
return run;
|
|
209
225
|
}
|
|
210
226
|
/* `ours`: { branch, head } just pushed from here: what it brings back is not news from the remote. */
|
|
211
227
|
async #refreshLocked(r, ours = null) {
|
package/server/main.mjs
CHANGED
|
@@ -325,6 +325,9 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
325
325
|
/* Not in place is said, not fatal: no machine is then given /tools. */
|
|
326
326
|
await toolbox.prepare().catch((error) => console.error(error.message));
|
|
327
327
|
await Promise.resolve(all.ensureWork?.()).catch((error) => console.error(`work folders: ${error.message}`));
|
|
328
|
+
/* Should memory run out, a machine is stopped first, never this server, its front or ssh (04-11). */
|
|
329
|
+
const kept = await asHost(['server', 'protect'], { timeoutMs: 30_000 }).catch(() => ({ code: 1, stderr: 'not run' }));
|
|
330
|
+
if (kept.code) console.error(`protect: ${String(kept.stderr ?? '').trim() || `exit ${kept.code}`}`);
|
|
328
331
|
})();
|
|
329
332
|
const bounded = (promise, ms, what) => {
|
|
330
333
|
let timer;
|
|
@@ -528,7 +531,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
528
531
|
try { if (talk.event(name, { kind: 'tools-updated', text: 'Tools updated: restart it to use them all. Its work picks up where it was.', topic: 'Tools', actions: ['restart'] })) toolbox.told(name); } catch { /* its chat is off */ }
|
|
529
532
|
}
|
|
530
533
|
});
|
|
531
|
-
/* A TOOL THAT ASKS TO BE RESTARTED (02-11: to take up its tools, after an update): restarted by this server
|
|
534
|
+
/* A TOOL THAT ASKS TO BE RESTARTED (02-11: to take up its tools, after an update): its tool restarted by this server
|
|
532
535
|
once its turn has ended (its pulse no longer busy), said in its chat; once per ten minutes at most. */
|
|
533
536
|
const restartedAt = new Map();
|
|
534
537
|
const restartTimer = setInterval(() => {
|
|
@@ -538,8 +541,10 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
538
541
|
talk.restartTaken(name);
|
|
539
542
|
if (Date.now() - (restartedAt.get(name) ?? 0) < 10 * 60_000) continue;
|
|
540
543
|
restartedAt.set(name, Date.now());
|
|
541
|
-
|
|
542
|
-
void all.
|
|
544
|
+
/* Its tool only, never its machine (04-11: a machine restarted so did not start again). */
|
|
545
|
+
void all.restartTool(name).then((done) => {
|
|
546
|
+
if (done) try { talk.event(name, { kind: 'restarted', text: 'Its tool was restarted as it asked: its work picks up where it was.', topic: 'Restarted' }); } catch { /* its chat is off */ }
|
|
547
|
+
}).catch(() => {});
|
|
543
548
|
}
|
|
544
549
|
}, 15_000); restartTimer.unref?.();
|
|
545
550
|
/* The health of each machine, and folders that came loose put back: see health.mjs. */
|
package/server/serverlogs.mjs
CHANGED
|
@@ -67,4 +67,10 @@ export class ServerLogs {
|
|
|
67
67
|
if (r.code !== 0) throw new Refusal(502, `This server could not be started again: ${String(r.stderr ?? '').trim().split('\n').pop()?.slice(0, 200) || `exit ${r.code}`}`);
|
|
68
68
|
return { restarting: true };
|
|
69
69
|
}
|
|
70
|
+
/* THE WHOLE SERVER STARTED AGAIN (04-11): its machines stop with it and start again after. */
|
|
71
|
+
async reboot() {
|
|
72
|
+
const r = await this.#host(['server', 'reboot']);
|
|
73
|
+
if (r.code !== 0) throw new Refusal(502, `This server could not be restarted: ${String(r.stderr ?? '').trim().split('\n').pop()?.slice(0, 200) || `exit ${r.code}`}`);
|
|
74
|
+
return { rebooting: true };
|
|
75
|
+
}
|
|
70
76
|
}
|
package/web/app.js
CHANGED
|
@@ -3554,7 +3554,8 @@
|
|
|
3554
3554
|
const r = await fetch(`${API}${path}`);
|
|
3555
3555
|
const j = await r.json().catch(() => ({}));
|
|
3556
3556
|
if (r.ok) return j;
|
|
3557
|
-
|
|
3557
|
+
/* Down for a moment, or its repository busy (another read holds it): asked again. */
|
|
3558
|
+
if (!(r.status === 503 && (j.down === true || j.kind === 'busy'))) return { state: 'error', message: j.error || 'It could not be read.' };
|
|
3558
3559
|
} catch { return { state: 'error', message: 'It could not be read.' }; }
|
|
3559
3560
|
await new Promise((ok) => setTimeout(ok, 1500 * (i + 1)));
|
|
3560
3561
|
}
|
|
@@ -3974,6 +3975,8 @@
|
|
|
3974
3975
|
const BRANCHES_MORE = 7;
|
|
3975
3976
|
/* What a row is, for the filter: a branch the remote has and that is ahead of it, a branch it does not have, nothing to send. */
|
|
3976
3977
|
const kindOfRow = (out) => (out?.state !== 'ahead' ? 'none' : out.targetExists === false ? 'new' : 'update');
|
|
3978
|
+
/* A branch that could not be read is not "nothing to send": it stays listed, under every filter, with why. */
|
|
3979
|
+
const unread = (out) => out?.state === 'error' || out?.state === 'unreachable';
|
|
3977
3980
|
const TS_FILTERS = [['update', 'To update'], ['new', 'New branches'], ['all', 'All']];
|
|
3978
3981
|
/* Three steps: every branch read (said as it goes, nothing checked yet); filtered and ticked; the checks of what is
|
|
3979
3982
|
ticked, on a click; then Send. */
|
|
@@ -3995,7 +3998,7 @@
|
|
|
3995
3998
|
let sending = false; let checking = false;
|
|
3996
3999
|
let sure = '';
|
|
3997
4000
|
let reposDone = 0; let reading = true;
|
|
3998
|
-
const shownRow = (r) => filter === 'all' || kindOfRow(r.out) === filter;
|
|
4001
|
+
const shownRow = (r) => filter === 'all' || kindOfRow(r.out) === filter || unread(r.out);
|
|
3999
4002
|
const picked = () => rows.filter((r) => r.picked && r.out?.state === 'ahead' && shownRow(r));
|
|
4000
4003
|
const label = (r) => (rows.filter((x) => x.name === r.name).length > 1 ? `${r.name} (${r.branch})` : r.name);
|
|
4001
4004
|
async function look(r) {
|
|
@@ -4040,7 +4043,12 @@
|
|
|
4040
4043
|
meter.hidden = !reading; meterFill.style.width = `${names.length ? Math.round((reposDone / names.length) * 100) : 100}%`;
|
|
4041
4044
|
progress.toggleAttribute('data-busy', reading);
|
|
4042
4045
|
if (reading) { progress.dataset.tone = 'warn'; progress.textContent = `Reading the repositories: ${reposDone} of ${names.length}${rows.length ? ` · ${rows.length} branch${rows.length === 1 ? '' : 'es'} found` : ''}`; }
|
|
4043
|
-
else {
|
|
4046
|
+
else {
|
|
4047
|
+
const failed = rows.filter((r) => unread(r.out)).length;
|
|
4048
|
+
const tail = failed ? ` · ${failed} not read` : ' · all read';
|
|
4049
|
+
progress.dataset.tone = failed ? 'warn' : count('update') + count('new') ? 'ok' : '';
|
|
4050
|
+
progress.textContent = count('update') + count('new') ? `${count('update')} to update · ${count('new')} new${tail}` : `Nothing to send${tail}`;
|
|
4051
|
+
}
|
|
4044
4052
|
filters.replaceChildren(...TS_FILTERS.map(([key, word]) => {
|
|
4045
4053
|
const n = key === 'all' ? rows.length : count(key);
|
|
4046
4054
|
const b = el('button', '', `${word} ${n}`); b.type = 'button'; b.dataset.filter = key; b.setAttribute('aria-pressed', String(filter === key));
|
|
@@ -4083,8 +4091,10 @@
|
|
|
4083
4091
|
tick.addEventListener('change', () => { r.picked = tick.checked; sure = ''; paint(); if (!review.hidden) paintReview(); });
|
|
4084
4092
|
const who = el('div', 'ts-who'); who.append(el('b', '', r.name), el('small', 'hint', out?.remote ? hostOf(out.remote) : out ? 'no remote' : ''));
|
|
4085
4093
|
const way = el('div', 'ts-way');
|
|
4086
|
-
|
|
4087
|
-
|
|
4094
|
+
/* Its own name even when it could not be read: which branch is missing is said. */
|
|
4095
|
+
const named = out?.branch ?? (unread(out) ? r.branch : '');
|
|
4096
|
+
if (named) {
|
|
4097
|
+
const code = el('code', 'ts-branch', named); code.title = named; way.append(code);
|
|
4088
4098
|
if (['ahead', 'up-to-date', 'diverged'].includes(out.state) && out.target) {
|
|
4089
4099
|
way.append(el('span', 'ts-arrow', '→'));
|
|
4090
4100
|
const to = el('select'); to.setAttribute('aria-label', `Where ${label(r)} goes`); to.disabled = sending || checking;
|
|
@@ -4300,7 +4310,7 @@
|
|
|
4300
4310
|
const r = { name, out: null, keep: first.keep, branch: b.name, target: '', picked: false, check: null, sent: null, movedAt: b.movedAt };
|
|
4301
4311
|
await look(r);
|
|
4302
4312
|
/* Ticked by one rule for every row: a branch of the remote to update is ticked; a new one is not. */
|
|
4303
|
-
if (r.out?.state === 'ahead') { r.picked = kindOfRow(r.out) === 'update'; rows.splice(rows.findLastIndex((x) => x.name === name) + 1, 0, r); }
|
|
4313
|
+
if (r.out?.state === 'ahead' || unread(r.out)) { r.picked = kindOfRow(r.out) === 'update'; rows.splice(rows.findLastIndex((x) => x.name === name) + 1, 0, r); }
|
|
4304
4314
|
paint();
|
|
4305
4315
|
}));
|
|
4306
4316
|
reposDone++; paint();
|
|
@@ -6630,17 +6640,20 @@
|
|
|
6630
6640
|
document.body.append(a); a.click(); a.remove();
|
|
6631
6641
|
setTimeout(() => URL.revokeObjectURL(a.href), 60_000);
|
|
6632
6642
|
});
|
|
6633
|
-
/*
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6643
|
+
/* CLAVARIUM, OR THE WHOLE SERVER, STARTED AGAIN: asked twice (the second says what it does).
|
|
6644
|
+
Clavarium: its program only, machines go on. The server (04-11): every machine stops with it. */
|
|
6645
|
+
for (const [id, path, kind, sure, label] of [['server-restart', 'restart', 'restart', 'Yes: restart Clavarium now', 'Restart Clavarium...'], ['server-reboot', 'reboot', 'reboot', 'Yes: stop every machine and restart the server', 'Restart the server...']]) {
|
|
6646
|
+
$(id).addEventListener('click', () => {
|
|
6647
|
+
const go = $(id);
|
|
6648
|
+
if (go.dataset.sure !== 'yes') { go.dataset.sure = 'yes'; go.textContent = sure; return; }
|
|
6649
|
+
go.disabled = true;
|
|
6650
|
+
void post(`${API}/server/${path}`, {}).then(() => {
|
|
6651
|
+
$(`${id}-said`).textContent = 'Restarting: this page comes back by itself.';
|
|
6652
|
+
/* The maintenance page waits for it (it answers a moment more before it stops), then comes back here. */
|
|
6653
|
+
location.replace(`/maintenance.html?${new URLSearchParams({ kind, back: location.pathname + location.search })}`);
|
|
6654
|
+
}).catch((error) => { $(`${id}-said`).textContent = error.message; go.disabled = false; delete go.dataset.sure; go.textContent = label; });
|
|
6655
|
+
});
|
|
6656
|
+
}
|
|
6644
6657
|
/* THE CURVES (server/history.mjs): memory, CPU and disk over time, one small chart each, one
|
|
6645
6658
|
line each on one scale (0 to 100 %); the reserve as a dotted level; a dot where a program
|
|
6646
6659
|
was stopped for lack of memory. Hovered or touched: the value and the time under it. */
|
package/web/index.html
CHANGED
|
@@ -1188,7 +1188,8 @@
|
|
|
1188
1188
|
<div class="row" id="logs-acts" hidden><button type="button" id="logs-copy">Copy all</button><button type="button" id="logs-save">Download</button></div>
|
|
1189
1189
|
<pre id="logs-text" class="logs-text" tabindex="0" hidden></pre>
|
|
1190
1190
|
<p class="hint">Secrets are masked. Newest at the bottom.</p>
|
|
1191
|
-
<div class="set-row"><div class="set-what"><span>Restart
|
|
1191
|
+
<div class="set-row"><div class="set-what"><span>Restart Clavarium</span><small id="server-restart-said" role="status">A few seconds; machines keep running</small></div><div class="set-control"><button type="button" class="danger" id="server-restart">Restart Clavarium...</button></div></div>
|
|
1192
|
+
<div class="set-row"><div class="set-what"><span>Restart the server</span><small id="server-reboot-said" role="status">A few minutes; every machine stops and starts again</small></div><div class="set-control"><button type="button" class="danger" id="server-reboot">Restart the server...</button></div></div>
|
|
1192
1193
|
</div>
|
|
1193
1194
|
</details>
|
|
1194
1195
|
<details class="chapter" id="settings-ch-about" data-chapter="s-about">
|