clavarium 0.2.404-next.1 → 0.2.405-next.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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/conversations.mjs +8 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.405-next.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.405-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/conversations.mjs
CHANGED
|
@@ -21,6 +21,8 @@ export const STOP_DELAY_MS = 60_000;
|
|
|
21
21
|
const STEP_MS = 15 * 60_000;
|
|
22
22
|
/* The door of a conversation in a shared machine (#221), put in the machine by the server. */
|
|
23
23
|
export const DOOR = new URL('../config/machine/clavarium-enter', import.meta.url);
|
|
24
|
+
/* The most programs one conversation may run in a shared machine. */
|
|
25
|
+
export const SHARED_PROCS = 1024;
|
|
24
26
|
/* Moving a work folder: what must stay free after it, and how long a copy may take. */
|
|
25
27
|
export const ROOM_MB = 1024;
|
|
26
28
|
/* A file shown straight from a machine's disk: where, and how large at most. */
|
|
@@ -444,6 +446,11 @@ export class Conversations {
|
|
|
444
446
|
const [uid, gid] = String(me.stdout ?? '').trim().split('\n').map(Number);
|
|
445
447
|
if (me.code !== 0 || !Number.isInteger(uid) || !Number.isInteger(gid)) return fail('Its own user could not be made', me);
|
|
446
448
|
this.#store.patch(name, { machineUser: { uid, gid } });
|
|
449
|
+
/* Its limits, read by its door at each entry: the memory chosen for it, and a bound on its programs -- one
|
|
450
|
+
conversation that runs away never takes the machine from the others. */
|
|
451
|
+
const limits = await this.#vms.execMachine(name, ['sudo', '-n', 'install', '-D', '-m', '0644', '-o', 'root', '-g', 'root', '/dev/stdin', `/etc/clavarium/limits/${name}`],
|
|
452
|
+
{ input: `mem=${Number(c.memoryMb) || tool.memoryMb}\nprocs=${SHARED_PROCS}\n`, timeoutMs: STEP_MS });
|
|
453
|
+
if (limits.code !== 0) return fail('Its limits could not be set in the shared machine', limits);
|
|
447
454
|
const kept = await this.#vms.workMake(name);
|
|
448
455
|
const shown = kept.code === 0 ? await this.#vms.workMount(name, this.#uid, this.#gid) : kept;
|
|
449
456
|
if (shown.code !== 0) return fail('The work folder could not be shown in the shared machine', shown);
|
|
@@ -1695,6 +1702,7 @@ export class Conversations {
|
|
|
1695
1702
|
await this.#vms.execMachine(name, ['sudo', '-n', 'pkill', '-KILL', '-u', `c-${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1696
1703
|
await this.#vms.workUnmount(name).catch(() => {});
|
|
1697
1704
|
if (erase) await this.#vms.execMachine(name, ['sudo', '-n', 'userdel', '--remove', `c-${name}`], { timeoutMs: 60_000 }).catch(() => {});
|
|
1705
|
+
if (erase) await this.#vms.execMachine(name, ['sudo', '-n', 'rm', '-f', `/etc/clavarium/limits/${name}`], { timeoutMs: 30_000 }).catch(() => {});
|
|
1698
1706
|
}
|
|
1699
1707
|
await this.#vms.unshare(name).catch(() => {});
|
|
1700
1708
|
const last = others.length === 0;
|