@roomi-fields/grillhouse 0.54.1 → 0.55.2
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +73 -0
- package/cadre/templates/projet/.github/workflows/ci.yml +4 -2
- package/cadre/templates/projet/.github/workflows/machine-vierge.yml +5 -42
- package/cadre/templates/projet/CONTRIBUTING.md +0 -5
- package/cadre/templates/projet/README.md +0 -126
- package/cadre/templates/projet/_npmignore +1 -6
- package/cadre/templates/projet/package.json +5 -32
- package/cadre/templates/projet/tsconfig.json +4 -4
- package/cadre/templates/projet/vitest.config.cjs +3 -2
- package/charte/tests.md +14 -0
- package/dist/machine/part-par-sorte.d.ts +9 -9
- package/dist/machine/part-par-sorte.js +20 -24
- package/dist/machine/part-par-sorte.js.map +1 -1
- package/dist/machine/table-des-consommations.d.ts +65 -0
- package/dist/machine/table-des-consommations.js +94 -0
- package/dist/machine/table-des-consommations.js.map +1 -0
- package/dist/temporal/circuit/activites.d.ts +2 -0
- package/dist/temporal/circuit/activites.js +87 -3
- package/dist/temporal/circuit/activites.js.map +1 -1
- package/dist/temporal/circuit/client.js +9 -4
- package/dist/temporal/circuit/client.js.map +1 -1
- package/dist/temporal/circuit/contrat.d.ts +32 -4
- package/dist/temporal/circuit/deroule.js +54 -4
- package/dist/temporal/circuit/deroule.js.map +1 -1
- package/dist/temporal/circuit/versions.d.ts +12 -0
- package/dist/temporal/circuit/versions.js +22 -0
- package/dist/temporal/circuit/versions.js.map +1 -0
- package/dist/temporal/consommation/activites.d.ts +2 -0
- package/dist/temporal/consommation/activites.js +9 -0
- package/dist/temporal/consommation/activites.js.map +1 -0
- package/dist/temporal/consommation/actualisation.d.ts +2 -0
- package/dist/temporal/consommation/actualisation.js +71 -0
- package/dist/temporal/consommation/actualisation.js.map +1 -0
- package/dist/temporal/consommation/client.d.ts +12 -0
- package/dist/temporal/consommation/client.js +28 -0
- package/dist/temporal/consommation/client.js.map +1 -0
- package/dist/temporal/consommation/commande.d.ts +5 -0
- package/dist/temporal/consommation/commande.js +32 -0
- package/dist/temporal/consommation/commande.js.map +1 -0
- package/dist/temporal/consommation/contrat.d.ts +15 -0
- package/dist/temporal/consommation/contrat.js +13 -0
- package/dist/temporal/consommation/contrat.js.map +1 -0
- package/dist/temporal/consommation/deroule.d.ts +2 -0
- package/dist/temporal/consommation/deroule.js +14 -0
- package/dist/temporal/consommation/deroule.js.map +1 -0
- package/dist/temporal/deroules.d.ts +2 -1
- package/dist/temporal/deroules.js +3 -2
- package/dist/temporal/deroules.js.map +1 -1
- package/dist/temporal/file/contrat.d.ts +2 -0
- package/dist/temporal/file/deroule.js +14 -4
- package/dist/temporal/file/deroule.js.map +1 -1
- package/dist/temporal/installation.d.ts +6 -0
- package/dist/temporal/installation.js +15 -0
- package/dist/temporal/installation.js.map +1 -1
- package/dist/temporal/nuits/activites.d.ts +2 -1
- package/dist/temporal/nuits/activites.js +127 -3
- package/dist/temporal/nuits/activites.js.map +1 -1
- package/dist/temporal/nuits/client.d.ts +19 -5
- package/dist/temporal/nuits/client.js +33 -23
- package/dist/temporal/nuits/client.js.map +1 -1
- package/dist/temporal/nuits/commande.js +16 -11
- package/dist/temporal/nuits/commande.js.map +1 -1
- package/dist/temporal/nuits/contrat.d.ts +29 -0
- package/dist/temporal/nuits/contrat.js +10 -0
- package/dist/temporal/nuits/contrat.js.map +1 -1
- package/dist/temporal/nuits/deroule.d.ts +5 -0
- package/dist/temporal/nuits/deroule.js +18 -1
- package/dist/temporal/nuits/deroule.js.map +1 -1
- package/dist/temporal/nuits/pc2.d.ts +72 -0
- package/dist/temporal/nuits/pc2.js +206 -0
- package/dist/temporal/nuits/pc2.js.map +1 -0
- package/dist/temporal/places/activites.d.ts +23 -1
- package/dist/temporal/places/activites.js +38 -2
- package/dist/temporal/places/activites.js.map +1 -1
- package/dist/temporal/places/client.d.ts +18 -2
- package/dist/temporal/places/client.js +28 -3
- package/dist/temporal/places/client.js.map +1 -1
- package/dist/temporal/places/contrat.d.ts +79 -14
- package/dist/temporal/places/contrat.js +7 -0
- package/dist/temporal/places/contrat.js.map +1 -1
- package/dist/temporal/places/deroule.js +159 -23
- package/dist/temporal/places/deroule.js.map +1 -1
- package/dist/temporal/places/reservation.d.ts +54 -0
- package/dist/temporal/places/reservation.js +69 -0
- package/dist/temporal/places/reservation.js.map +1 -0
- package/dist/temporal/planification.d.ts +6 -0
- package/dist/temporal/planification.js +26 -0
- package/dist/temporal/planification.js.map +1 -0
- package/dist/temporal/tickets/activites.d.ts +0 -2
- package/dist/temporal/tickets/activites.js +2 -52
- package/dist/temporal/tickets/activites.js.map +1 -1
- package/dist/temporal/tickets/contrat.d.ts +7 -26
- package/dist/temporal/tickets/deroule.js +35 -23
- package/dist/temporal/tickets/deroule.js.map +1 -1
- package/dist/temporal/travailleur.js +2 -0
- package/dist/temporal/travailleur.js.map +1 -1
- package/docs/ARCHITECTURE.md +2 -2
- package/docs/CADRE.md +1 -1
- package/docs/INTERFACE.md +16 -11
- package/docs/architecture/circuit.md +62 -58
- package/docs/architecture/entree.md +87 -63
- package/docs/architecture/greffon.md +24 -21
- package/docs/architecture/installation.md +35 -30
- package/docs/architecture/machine.md +48 -40
- package/docs/architecture/tests.md +37 -33
- package/docs/lexique.md +4 -3
- package/package.json +1 -1
- package/scripts/activites.mjs +351 -180
- package/scripts/aiguillage.mjs +1 -0
- package/scripts/attente-de-la-machine.mjs +3 -22
- package/scripts/avancement.mjs +21 -30
- package/scripts/bilan.mjs +22 -2
- package/scripts/branche-de-nuit.mjs +1 -1
- package/scripts/circuit.mjs +75 -39
- package/scripts/codes-de-sortie.mjs +0 -6
- package/scripts/coeurs-dedies.mjs +19 -2
- package/scripts/consommation-des-passes.mjs +67 -35
- package/scripts/consommation.mjs +152 -24
- package/scripts/copies-finies.mjs +15 -35
- package/scripts/dernier-vert.mjs +4 -5
- package/scripts/dette.mjs +5 -3
- package/scripts/droits.mjs +2 -2
- package/scripts/echantillonneur-de-la-passe.mjs +7 -31
- package/scripts/engendres.mjs +5 -61
- package/scripts/enveloppe/enveloppe.mjs +30 -34
- package/scripts/enveloppe/travail-de-la-copie.mjs +5 -0
- package/scripts/etapes.mjs +21 -7
- package/scripts/etat-du-depot.mjs +61 -0
- package/scripts/faits-du-circuit.mjs +7 -4
- package/scripts/fermeture-de-la-machine.d.mts +6 -4
- package/scripts/fermeture-de-la-machine.mjs +12 -16
- package/scripts/fichier-du-poste.d.mts +9 -0
- package/scripts/file-des-tickets.d.mts +0 -18
- package/scripts/file-des-tickets.mjs +0 -42
- package/scripts/fusion-du-changelog.mjs +1 -1
- package/scripts/grillhouse-maj.mjs +1 -1
- package/scripts/index-des-rouges.d.mts +40 -0
- package/scripts/index-des-rouges.mjs +104 -0
- package/scripts/integration/file.mjs +13 -63
- package/scripts/integration/integrer.mjs +157 -424
- package/scripts/integration/jugement.mjs +109 -0
- package/scripts/integration/rejeu.mjs +94 -71
- package/scripts/jointure.d.ts +34 -27
- package/scripts/journal-des-etats.d.mts +1 -1
- package/scripts/langages/c/commandes.mjs +27 -12
- package/scripts/langages/cargo/commandes.mjs +148 -94
- package/scripts/langages/cargo/index.mjs +2 -1
- package/scripts/langages/cargo/lectures-des-tests.mjs +132 -0
- package/scripts/langages/cargo/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/python/commandes.mjs +31 -15
- package/scripts/langages/python/index.mjs +2 -1
- package/scripts/langages/python/lectures-des-tests.mjs +148 -0
- package/scripts/langages/python/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/typescript/consommateurs-arbitres.mjs +2 -2
- package/scripts/langages/typescript/index.mjs +4 -0
- package/scripts/langages/typescript/lectures-des-tests.mjs +95 -0
- package/scripts/langages/typescript/migrations/lectures-des-tests.mjs +31 -0
- package/scripts/langages/typescript/tests-de-nuit.mjs +9 -15
- package/scripts/langages/typescript/tests.mjs +11 -37
- package/scripts/langages/typescript/titres-de-tests.mjs +5 -4
- package/scripts/langages/typescript/verifier.mjs +74 -44
- package/scripts/langages/typescript/vitest-config/base.mjs +3 -3
- package/scripts/langages/typescript/vitest-config/machine.setup.mjs +6 -25
- package/scripts/lectures-communes.mjs +234 -0
- package/scripts/machine.mjs +11 -18
- package/scripts/mesure/base-de-passe.mjs +1 -2
- package/scripts/mesure-de-la-machine.d.mts +43 -3
- package/scripts/mesure-de-la-machine.mjs +209 -11
- package/scripts/migrations/0.33.0-ci-du-cadre.mjs +3 -3
- package/scripts/migrations/nuit-yml-retire.mjs +25 -0
- package/scripts/migrations/part-retiree.mjs +31 -0
- package/scripts/migrations/table-des-consommations.mjs +36 -0
- package/scripts/migrations.mjs +6 -0
- package/scripts/montee.mjs +9 -0
- package/scripts/nuit-de-pc2.mjs +628 -0
- package/scripts/nuit.sh +8 -131
- package/scripts/paquets.mjs +1 -1
- package/scripts/passe-de-la-machine.mjs +365 -105
- package/scripts/place-du-circuit.d.mts +15 -0
- package/scripts/place-du-circuit.mjs +32 -0
- package/scripts/places-de-la-machine.mjs +148 -627
- package/scripts/places-du-serveur.mjs +43 -16
- package/scripts/plafond-de-la-machine.d.mts +8 -13
- package/scripts/plafond-de-la-machine.mjs +37 -69
- package/scripts/registre-des-entrees.mjs +57 -0
- package/scripts/regles-des-places.d.mts +84 -50
- package/scripts/regles-des-places.mjs +200 -156
- package/scripts/retirer-copie.sh +2 -2
- package/scripts/seances.mjs +181 -63
- package/scripts/secours.mjs +95 -0
- package/scripts/services-du-noyau.mjs +11 -19
- package/scripts/sous-commandes.mjs +1 -0
- package/scripts/sous-modules.sh +1 -1
- package/scripts/superviseur.mjs +16 -7
- package/scripts/table-des-consommations.d.mts +9 -0
- package/scripts/table-des-consommations.mjs +35 -0
- package/scripts/tableau.mjs +33 -19
- package/scripts/taches-du-graphe.mjs +124 -2
- package/scripts/transitions.d.mts +27 -5
- package/scripts/transitions.mjs +125 -104
- package/scripts/verdict-de-la-nuit.d.mts +13 -0
- package/scripts/verdict-de-la-nuit.mjs +34 -7
- package/scripts/verrou-de-fichier.mjs +1 -2
- package/scripts/workflows-du-cadre.mjs +2 -2
- package/skills/developpeur/SKILL.md +8 -2
- package/skills/direct/SKILL.md +5 -0
- package/skills/explorateur/SKILL.md +10 -1
- package/skills/grill/SKILL.md +2 -4
- package/skills/pitmaster/SKILL.md +7 -5
- package/skills/pitmaster/references/consigne-agent.md +1 -1
- package/skills/relecteur/SKILL.md +4 -1
- package/skills/testwriter/SKILL.md +15 -2
- package/cadre/templates/projet/.env.example +0 -57
- package/cadre/templates/projet/.github/workflows/nuit.yml +0 -139
- package/cadre/templates/projet/deployment/README.md +0 -98
- package/cadre/templates/projet/deployment/docs/01-INSTALL.md +0 -145
- package/cadre/templates/projet/deployment/docs/02-CONFIGURATION.md +0 -117
- package/cadre/templates/projet/deployment/docs/03-API.md +0 -264
- package/cadre/templates/projet/deployment/docs/04-TROUBLESHOOTING.md +0 -262
- package/cadre/templates/projet/deployment/scripts/install.ps1 +0 -100
- package/cadre/templates/projet/deployment/scripts/start.ps1 +0 -61
- package/cadre/templates/projet/deployment/scripts/stop.ps1 +0 -37
- package/cadre/templates/projet/deployment/scripts/test.ps1 +0 -118
- package/cadre/templates/projet/ecosystem.config.cjs +0 -73
- package/cadre/templates/projet/src/config.ts +0 -68
- package/cadre/templates/projet/src/errors.ts +0 -102
- package/cadre/templates/projet/src/index.ts +0 -46
- package/cadre/templates/projet/src/services/.gitkeep +0 -8
- package/cadre/templates/projet/src/types/index.ts +0 -24
- package/cadre/templates/projet/src/utils/logger.ts +0 -106
- package/cadre/templates/projet/tests/unit/config.spec.ts +0 -68
- package/cadre/templates/projet/tests/unit/errors.spec.ts +0 -132
- package/cadre/templates/projet/tests/unit/types.spec.ts +0 -73
- package/cadre/templates/projet/tsconfig.build.json +0 -14
- package/scripts/flux-de-la-nuit.mjs +0 -39
- package/scripts/garde-de-la-memoire.mjs +0 -231
- package/scripts/repli-de-la-nuit.mjs +0 -184
|
@@ -11,9 +11,44 @@ export function lireLaMemoire(texte: string): { disponible: number | null; echan
|
|
|
11
11
|
/** What the machine still gives now: the memory available and the free swap, in bytes. */
|
|
12
12
|
export function memoireRestante(): { disponible: number | null; echange: number };
|
|
13
13
|
|
|
14
|
-
/** The
|
|
14
|
+
/** The window the cores occupied are read on, in ms: ten seconds. */
|
|
15
|
+
export const FENETRE_DE_CHARGE_MS: number;
|
|
16
|
+
|
|
17
|
+
/** The idle and the total processor time the aggregate line of <texte> (/proc/stat) says; null without it. */
|
|
18
|
+
export function lireLeTempsDuProcesseur(texte: string): { inactif: number; total: number } | null;
|
|
19
|
+
|
|
20
|
+
/** The cores occupied over the last ten seconds, from the samples of /proc/stat. */
|
|
21
|
+
export function coeursOccupes(
|
|
22
|
+
echantillons: readonly { t: number; inactif: number; total: number }[],
|
|
23
|
+
o: { coeurs: number; maintenant: number }
|
|
24
|
+
): number;
|
|
25
|
+
|
|
26
|
+
/** The pressure `full avg10` of the memory in <texte> (/proc/pressure/memory), in %; null without. */
|
|
27
|
+
export function lireLaPressionDeLaMemoire(texte: string): number | null;
|
|
28
|
+
|
|
29
|
+
/** What the watch of the arbiter reads of the memory now (bytes, %). */
|
|
30
|
+
export function lireLaMemoireSurveillee(): {
|
|
31
|
+
pression: number | null;
|
|
32
|
+
disponible: number | null;
|
|
33
|
+
echangeEnMemoire: number;
|
|
34
|
+
echangeSurDisqueUtilise: number;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** The memory the group of the step <id> holds now, in bytes; null when it does not answer. */
|
|
38
|
+
export function memoireDeLEtape(id: string): number | null;
|
|
39
|
+
|
|
40
|
+
/** Stops the group of the step <id> (SIGTERM, then SIGKILL); false when it has none. */
|
|
41
|
+
export function arreterLEtape(id: string, delaiMs?: number): boolean;
|
|
42
|
+
|
|
43
|
+
/** The scope of the group of the step <id>. */
|
|
44
|
+
export function uniteDeLEtape(id: string): string;
|
|
45
|
+
|
|
46
|
+
/** The machine now: its cores, the cores occupied over ten seconds, its free memory in bytes. */
|
|
15
47
|
export function mesureDeLaMachine(): MesureDeLaMachine;
|
|
16
48
|
|
|
49
|
+
/** The cores of the machine, on its topology, never the affinity of the process. */
|
|
50
|
+
export function coeursDeLaMachine(): number;
|
|
51
|
+
|
|
17
52
|
/** The start of the process <pid> as the system gives it, null when it is gone. */
|
|
18
53
|
export function departDe(pid: number): string | null;
|
|
19
54
|
|
|
@@ -21,7 +56,12 @@ export function departDe(pid: number): string | null;
|
|
|
21
56
|
export function processusVivant(p: { pid: number; depart: string | null }): boolean;
|
|
22
57
|
|
|
23
58
|
/** <signal> to the process group <groupe>; false when the group is gone. */
|
|
24
|
-
export function signalerGroupe(
|
|
59
|
+
export function signalerGroupe(
|
|
60
|
+
groupe: number | null | undefined,
|
|
61
|
+
signal: NodeJS.Signals | 0
|
|
62
|
+
): boolean;
|
|
25
63
|
|
|
26
64
|
/** Whether the group a sign of life <vie> names still runs, its leader dead or alive. */
|
|
27
|
-
export function groupeVivant(
|
|
65
|
+
export function groupeVivant(
|
|
66
|
+
vie: { pid: number; depart?: string | null } | null | undefined
|
|
67
|
+
): boolean;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// What the machine gives at a moment, which the admission of a start reads
|
|
2
|
-
// (scripts/regles-des-places.mjs): its cores,
|
|
3
|
-
// total memory, which the board shows beside it. The
|
|
2
|
+
// (scripts/regles-des-places.mjs): its cores, the cores occupied over the last ten seconds (read
|
|
3
|
+
// on the idle time of /proc/stat), its free memory, and its total memory, which the board shows beside it. The
|
|
4
4
|
// activity of the workflow of the machine (src/temporal/places/activites.ts) measures it here, and
|
|
5
5
|
// whether the process of a place still lives; a signal to a process group, and whether the group
|
|
6
6
|
// a sign of life names still runs, which the sessions (scripts/seances.mjs), the circuit and the
|
|
7
7
|
// acts under Temporal (src/temporal/acte.ts) share. Architecture: docs/architecture/machine.md
|
|
8
8
|
// (§3.1, §5.2).
|
|
9
|
+
import { spawnSync } from 'node:child_process';
|
|
9
10
|
import { readFileSync } from 'node:fs';
|
|
10
|
-
import {
|
|
11
|
+
import { cpus, freemem, totalmem } from 'node:os';
|
|
11
12
|
import { departDe, leMemeVivant, vivant } from './mesure/base-de-passe.mjs';
|
|
12
13
|
|
|
13
14
|
export { departDe };
|
|
@@ -40,6 +41,107 @@ export function memoireRestante() {
|
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
|
|
44
|
+
/**
|
|
45
|
+
* The pressure `full avg10` of the memory in <texte> (/proc/pressure/memory), in %: the share of
|
|
46
|
+
* the last ten seconds in which every task waited for memory; null when it does not say it.
|
|
47
|
+
* @param {string} texte
|
|
48
|
+
* @returns {number | null}
|
|
49
|
+
*/
|
|
50
|
+
export function lireLaPressionDeLaMemoire(texte) {
|
|
51
|
+
const m = /^full\b.*\bavg10=(\d+(?:\.\d+)?)/m.exec(texte);
|
|
52
|
+
return m ? Number(m[1]) : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The swap <texte> (/proc/swaps) says, in bytes: what is free in a swap held in memory (zram) and
|
|
57
|
+
* what is used on a disk.
|
|
58
|
+
* @param {string} texte
|
|
59
|
+
* @returns {{ enMemoire: number, surDisque: number }}
|
|
60
|
+
*/
|
|
61
|
+
export function lireLesEchanges(texte) {
|
|
62
|
+
let enMemoire = 0;
|
|
63
|
+
let surDisque = 0;
|
|
64
|
+
for (const ligne of texte.split('\n').slice(1)) {
|
|
65
|
+
const [fichier, , taille, utilise] = ligne.trim().split(/\s+/);
|
|
66
|
+
if (!fichier || !/^\d+$/.test(taille ?? '') || !/^\d+$/.test(utilise ?? '')) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (/\/zram\d+$/.test(fichier)) {
|
|
70
|
+
enMemoire += (Number(taille) - Number(utilise)) * 1024;
|
|
71
|
+
} else {
|
|
72
|
+
surDisque += Number(utilise) * 1024;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return { enMemoire, surDisque };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const lireOuVide = fichier => {
|
|
79
|
+
try {
|
|
80
|
+
return readFileSync(fichier, 'utf8');
|
|
81
|
+
} catch {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* What the watch of the arbiter reads of the memory now: the pressure (null where the machine
|
|
88
|
+
* does not say it), the memory available (null likewise), the swap free in memory and the swap
|
|
89
|
+
* used on disk, in bytes.
|
|
90
|
+
* @returns {{ pression: number | null, disponible: number | null, echangeEnMemoire: number,
|
|
91
|
+
* echangeSurDisqueUtilise: number }}
|
|
92
|
+
*/
|
|
93
|
+
export function lireLaMemoireSurveillee() {
|
|
94
|
+
const pression = lireOuVide('/proc/pressure/memory');
|
|
95
|
+
const echanges = lireLesEchanges(lireOuVide('/proc/swaps') ?? '');
|
|
96
|
+
return {
|
|
97
|
+
pression: pression === null ? null : lireLaPressionDeLaMemoire(pression),
|
|
98
|
+
disponible: memoireRestante().disponible,
|
|
99
|
+
echangeEnMemoire: echanges.enMemoire,
|
|
100
|
+
echangeSurDisqueUtilise: echanges.surDisque,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** The scope of the group of a step: a pass or a session is named after the id of its reservation. */
|
|
105
|
+
export const uniteDeLEtape = id => `grillhouse-passe-${id}.scope`;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The memory the group of the step <id> holds now, in bytes; null when the group does not answer.
|
|
109
|
+
* @param {string} id
|
|
110
|
+
* @returns {number | null}
|
|
111
|
+
*/
|
|
112
|
+
export function memoireDeLEtape(id) {
|
|
113
|
+
const r = spawnSync(
|
|
114
|
+
'systemctl',
|
|
115
|
+
['--user', 'show', uniteDeLEtape(id), '-p', 'MemoryCurrent', '--value'],
|
|
116
|
+
{
|
|
117
|
+
encoding: 'utf8',
|
|
118
|
+
timeout: 10_000,
|
|
119
|
+
}
|
|
120
|
+
);
|
|
121
|
+
const n = Number((r.stdout ?? '').trim());
|
|
122
|
+
return r.status === 0 && Number.isFinite(n) && /^\d+$/.test((r.stdout ?? '').trim()) ? n : null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Stops the group of the step <id> and every process in it (SIGTERM, then SIGKILL after
|
|
127
|
+
* <delaiMs>); false when the system has no such group.
|
|
128
|
+
* @param {string} id
|
|
129
|
+
* @param {number} [delaiMs]
|
|
130
|
+
* @returns {boolean}
|
|
131
|
+
*/
|
|
132
|
+
export function arreterLEtape(id, delaiMs = 5000) {
|
|
133
|
+
const signaler = signal =>
|
|
134
|
+
spawnSync('systemctl', ['--user', 'kill', `--signal=${signal}`, uniteDeLEtape(id)], {
|
|
135
|
+
timeout: 10_000,
|
|
136
|
+
}).status === 0;
|
|
137
|
+
if (!signaler('SIGTERM')) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, delaiMs);
|
|
141
|
+
signaler('SIGKILL');
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
|
|
43
145
|
/**
|
|
44
146
|
* The memory available now, in bytes (MemAvailable of the kernel, else the free memory of node).
|
|
45
147
|
* @returns {number}
|
|
@@ -49,16 +151,112 @@ export function memoireDisponible() {
|
|
|
49
151
|
}
|
|
50
152
|
|
|
51
153
|
/**
|
|
52
|
-
* The
|
|
53
|
-
* the
|
|
154
|
+
* The cores of the machine, counted on its topology (the processors the system lists), never on
|
|
155
|
+
* the affinity of the calling process: a process confined to 6 cores sees the same machine, so the
|
|
156
|
+
* budget does not depend on who measures it.
|
|
157
|
+
* @returns {number}
|
|
158
|
+
*/
|
|
159
|
+
export const coeursDeLaMachine = () => Math.max(1, cpus().length);
|
|
160
|
+
|
|
161
|
+
/** The window the cores occupied are read on, in ms: the last ten seconds. */
|
|
162
|
+
export const FENETRE_DE_CHARGE_MS = 10_000;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The processor time the aggregate line `cpu` of <texte> (/proc/stat) says, in clock ticks: the
|
|
166
|
+
* idle time (idle and iowait) and the total (the eight first fields, steal included); null without
|
|
167
|
+
* that line. The lines of each core (`cpu0`…) are not read.
|
|
168
|
+
* @param {string} texte
|
|
169
|
+
* @returns {{ inactif: number, total: number } | null}
|
|
170
|
+
*/
|
|
171
|
+
export function lireLeTempsDuProcesseur(texte) {
|
|
172
|
+
const ligne = /^cpu\s+(.*)$/m.exec(texte);
|
|
173
|
+
if (!ligne) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
const champs = ligne[1].trim().split(/\s+/).map(Number);
|
|
177
|
+
return {
|
|
178
|
+
inactif: (champs[3] ?? 0) + (champs[4] ?? 0),
|
|
179
|
+
total: champs.slice(0, 8).reduce((n, c) => n + (c || 0), 0),
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* The cores occupied over the last FENETRE_DE_CHARGE_MS before <maintenant>: the cores times the
|
|
185
|
+
* occupied share of the processor time between the oldest sample of the window and the last. A
|
|
186
|
+
* sample is `{ t, inactif, total }` (`t` in ms, the times of `lireLeTempsDuProcesseur`); no time
|
|
187
|
+
* elapsed between them gives zero.
|
|
188
|
+
* @param {{ t: number, inactif: number, total: number }[]} echantillons in order
|
|
189
|
+
* @param {{ coeurs: number, maintenant: number }} o
|
|
190
|
+
* @returns {number}
|
|
191
|
+
*/
|
|
192
|
+
export function coeursOccupes(echantillons, { coeurs, maintenant }) {
|
|
193
|
+
const dernier = echantillons.at(-1);
|
|
194
|
+
const debut = echantillons.find(e => e.t >= maintenant - FENETRE_DE_CHARGE_MS);
|
|
195
|
+
if (!dernier || !debut) {
|
|
196
|
+
return 0;
|
|
197
|
+
}
|
|
198
|
+
const total = dernier.total - debut.total;
|
|
199
|
+
if (total <= 0) {
|
|
200
|
+
return 0;
|
|
201
|
+
}
|
|
202
|
+
const occupee = 1 - (dernier.inactif - debut.inactif) / total;
|
|
203
|
+
return Math.min(coeurs, Math.max(0, coeurs * occupee));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// The samples of the processor time this process took, the window and the one before it.
|
|
207
|
+
const echantillons = [];
|
|
208
|
+
const PAUSE_DU_PREMIER_RELEVE_MS = 200;
|
|
209
|
+
|
|
210
|
+
// Takes a sample now; false where /proc/stat does not read.
|
|
211
|
+
function echantillonner() {
|
|
212
|
+
try {
|
|
213
|
+
const temps = lireLeTempsDuProcesseur(readFileSync('/proc/stat', 'utf8'));
|
|
214
|
+
if (!temps) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
const t = Date.now();
|
|
218
|
+
echantillons.push({ t, ...temps });
|
|
219
|
+
while (echantillons.length > 2 && echantillons[1].t < t - FENETRE_DE_CHARGE_MS) {
|
|
220
|
+
echantillons.shift();
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
223
|
+
} catch {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The cores occupied now over the last ten seconds, on /proc/stat: a long-lived process (the
|
|
230
|
+
* arbiter) samples at each call and reads its window; a first call has no past, and waits a
|
|
231
|
+
* moment between two samples. Zero where /proc/stat does not read.
|
|
232
|
+
* @param {number} coeurs
|
|
233
|
+
* @returns {number}
|
|
234
|
+
*/
|
|
235
|
+
function coeursOccupesMaintenant(coeurs) {
|
|
236
|
+
if (!echantillonner()) {
|
|
237
|
+
return 0;
|
|
238
|
+
}
|
|
239
|
+
if (echantillons.length < 2) {
|
|
240
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, PAUSE_DU_PREMIER_RELEVE_MS);
|
|
241
|
+
echantillonner();
|
|
242
|
+
}
|
|
243
|
+
return coeursOccupes(echantillons, { coeurs, maintenant: Date.now() });
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The machine now: `{ coeurs, charge, memoireLibre, memoireTotale }`, `charge` the cores occupied
|
|
248
|
+
* over the last ten seconds, the memories in bytes.
|
|
54
249
|
* @returns {{ coeurs: number, charge: number, memoireLibre: number, memoireTotale: number }}
|
|
55
250
|
*/
|
|
56
|
-
export const mesureDeLaMachine = () =>
|
|
57
|
-
coeurs
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
251
|
+
export const mesureDeLaMachine = () => {
|
|
252
|
+
const coeurs = coeursDeLaMachine();
|
|
253
|
+
return {
|
|
254
|
+
coeurs,
|
|
255
|
+
charge: coeursOccupesMaintenant(coeurs),
|
|
256
|
+
memoireLibre: memoireDisponible(),
|
|
257
|
+
memoireTotale: totalmem(),
|
|
258
|
+
};
|
|
259
|
+
};
|
|
62
260
|
|
|
63
261
|
/**
|
|
64
262
|
* Whether the process <pid> lives and is the one of its start <depart> (`departDe`; any process
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// The frame carries the CI of a project: the template's `.github/workflows/ci.yml
|
|
2
|
-
//
|
|
1
|
+
// The frame carries the CI of a project: the template's `.github/workflows/ci.yml`,
|
|
2
|
+
// bearing the frame's mark on its first line (scripts/workflows-du-cadre.mjs). Mechanism:
|
|
3
3
|
// installation.md §5.2 and §5.4 (packages/grillhouse/docs/architecture/).
|
|
4
4
|
//
|
|
5
5
|
// - The migration changes no file: a project's CI is its own until it adopts the frame's.
|
|
@@ -23,6 +23,6 @@ export function restes(projet) {
|
|
|
23
23
|
}
|
|
24
24
|
const modele = path.relative(projet, path.join(CADRE, GABARIT_DES_WORKFLOWS, 'ci.yml'));
|
|
25
25
|
return [
|
|
26
|
-
`${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches
|
|
26
|
+
`${WORKFLOWS} : le cadre porte la CI d'un projet (ci.yml, le lot en tranches). Pour l'adopter, copier \`${modele}\` dans \`${WORKFLOWS}/\` (un ci.yml du projet cède sa place, ses étapes propres versées ailleurs), puis \`npx grillhouse maj\`, qui le tient à jour. Leur machine : la variable RUNNER du dépôt sur GitHub, facultative (ubuntu-latest sans elle).`,
|
|
27
27
|
];
|
|
28
28
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// The night no longer plays on GitHub: the frame neither reads nor writes `.github/workflows/nuit.yml`
|
|
2
|
+
// any more (entree.md §5.3). The file of a project that bears the frame's mark on its first line is
|
|
3
|
+
// removed; one without the mark is the project's own, stays, and is reported. Mechanism:
|
|
4
|
+
// installation.md §5.4 (packages/grillhouse/docs/architecture/).
|
|
5
|
+
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { estDuCadre, WORKFLOWS } from '../workflows-du-cadre.mjs';
|
|
8
|
+
|
|
9
|
+
// Not released yet: it plays for a project that recorded no version or one below the package's.
|
|
10
|
+
export const version = '0.55.0';
|
|
11
|
+
export const nom = 'nuit yml retire';
|
|
12
|
+
|
|
13
|
+
/** The `nuit.yml` of the frame removed from the project at <projet>; returns what it did. */
|
|
14
|
+
export function migrer(projet) {
|
|
15
|
+
const relatif = `${WORKFLOWS}/nuit.yml`;
|
|
16
|
+
const fichier = path.join(projet, relatif);
|
|
17
|
+
if (!existsSync(fichier)) {
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
if (estDuCadre(readFileSync(fichier, 'utf8'))) {
|
|
21
|
+
rmSync(fichier);
|
|
22
|
+
return [`${relatif} : le flux de la nuit du cadre est retiré, la nuit ne tourne plus sur GitHub`];
|
|
23
|
+
}
|
|
24
|
+
return [`${relatif} : nuit.yml du projet, que le cadre ne lit plus : à retirer ou à garder`];
|
|
25
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// A project holds no key `grillhouse.part`: the reservation of a pass comes from the table of the
|
|
2
|
+
// consumptions of its sort, which the arbiter admits, and nothing reads the key any more. The key
|
|
3
|
+
// goes from the package.json of the project, its other keys `grillhouse.*`, its layout and its end of
|
|
4
|
+
// line kept, and the `grillhouse` object that held nothing else goes with it. Mechanism:
|
|
5
|
+
// installation.md §5.4 (packages/grillhouse/docs/architecture/).
|
|
6
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
|
|
9
|
+
// Not released yet: it plays for a project that recorded no version or one below the package's.
|
|
10
|
+
export const version = '0.55.0';
|
|
11
|
+
export const nom = 'part retiree';
|
|
12
|
+
|
|
13
|
+
/** The key `grillhouse.part` removed from the package.json of <projet>; returns what it did. */
|
|
14
|
+
export function migrer(projet) {
|
|
15
|
+
const fichier = path.join(projet, 'package.json');
|
|
16
|
+
if (!existsSync(fichier)) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const texte = readFileSync(fichier, 'utf8');
|
|
20
|
+
const pkg = JSON.parse(texte);
|
|
21
|
+
if (!pkg?.grillhouse || typeof pkg.grillhouse !== 'object' || !('part' in pkg.grillhouse)) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
delete pkg.grillhouse.part;
|
|
25
|
+
const indent = /^\n?(\s+)"/m.exec(texte)?.[1] ?? 2;
|
|
26
|
+
const fin = texte.endsWith('\n') ? '\n' : '';
|
|
27
|
+
writeFileSync(fichier, `${JSON.stringify(pkg, null, indent)}${fin}`);
|
|
28
|
+
return [
|
|
29
|
+
'package.json : la clé grillhouse.part est retirée, la réservation d’une passe vient de la table des consommations',
|
|
30
|
+
];
|
|
31
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// A project holds the table of the consumptions of its phases: the reservation of a step comes
|
|
2
|
+
// from it (machine.md §5.2, §5.6), and a project mounted before the first daily recalculation had
|
|
3
|
+
// none, so every phase took the default part. The migration writes it once
|
|
4
|
+
// (`grillhouse consommation --ecrire`); the daily recalculation then rewrites it. Mechanism:
|
|
5
|
+
// installation.md §5.4 (packages/grillhouse/docs/architecture/).
|
|
6
|
+
import { existsSync } from 'node:fs';
|
|
7
|
+
import { consommation } from '../consommation.mjs';
|
|
8
|
+
import { fichierDeLaTable } from '../table-des-consommations.mjs';
|
|
9
|
+
|
|
10
|
+
// No version before its release: `grillhouse sortie` numbers it.
|
|
11
|
+
export const version = '0.55.2';
|
|
12
|
+
export const nom = 'table des consommations';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The table of the consumptions written for <projet> when it holds none; returns what it could not do (the writing itself is silent: the table is data).
|
|
16
|
+
* A table already there is left to the daily recalculation.
|
|
17
|
+
* @param {string} projet
|
|
18
|
+
* @param {{ ecrire?: (racine: string) => number | Promise<number> }} [o] the writing, for a trial
|
|
19
|
+
* @returns {string[]}
|
|
20
|
+
*/
|
|
21
|
+
export function migrer(projet, { ecrire } = {}) {
|
|
22
|
+
const fichier = fichierDeLaTable(projet);
|
|
23
|
+
if (fichier === null || existsSync(fichier)) {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const jouer =
|
|
27
|
+
ecrire ?? (racine => consommation({ args: ['--ecrire'], racine, ecrire: () => undefined }));
|
|
28
|
+
try {
|
|
29
|
+
const code = jouer(projet);
|
|
30
|
+
return existsSync(fichier)
|
|
31
|
+
? []
|
|
32
|
+
: [`la table des consommations n'est pas écrite (code ${String(code)}) : \`grillhouse consommation --ecrire\` la pose`];
|
|
33
|
+
} catch (e) {
|
|
34
|
+
return [`la table des consommations n'est pas écrite : ${(e instanceof Error ? e.message : String(e))}`];
|
|
35
|
+
}
|
|
36
|
+
}
|
package/scripts/migrations.mjs
CHANGED
|
@@ -54,6 +54,9 @@ import * as reservationDeTroisCoeurs from './migrations/0.49.0-reservation-de-tr
|
|
|
54
54
|
|
|
55
55
|
import * as reglagesHorsDeLaCharte from './migrations/0.50.0-reglages-hors-de-la-charte.mjs';
|
|
56
56
|
import * as lireUnTicket from './migrations/lire-un-ticket.mjs';
|
|
57
|
+
import * as partRetiree from './migrations/part-retiree.mjs';
|
|
58
|
+
import * as tableDesConsommations from './migrations/table-des-consommations.mjs';
|
|
59
|
+
import * as nuitYmlRetire from './migrations/nuit-yml-retire.mjs';
|
|
57
60
|
import * as serveursDeLIndex from './migrations/serveurs-de-l-index.mjs';
|
|
58
61
|
import * as coutDesJetons from './migrations/cout-des-jetons-au-registre.mjs';
|
|
59
62
|
import * as suiviDuSuperviseurRetire from './migrations/suivi-du-superviseur-retire.mjs';
|
|
@@ -86,6 +89,9 @@ export const MIGRATIONS = [
|
|
|
86
89
|
coutDesJetons,
|
|
87
90
|
suiviDuSuperviseurRetire,
|
|
88
91
|
lireUnTicket,
|
|
92
|
+
partRetiree,
|
|
93
|
+
tableDesConsommations,
|
|
94
|
+
nuitYmlRetire,
|
|
89
95
|
];
|
|
90
96
|
|
|
91
97
|
/**
|
package/scripts/montee.mjs
CHANGED
|
@@ -385,6 +385,15 @@ export function jouerLePoste(montee, echoues = []) {
|
|
|
385
385
|
['--planifier']
|
|
386
386
|
)
|
|
387
387
|
);
|
|
388
|
+
essayer('npx grillhouse consommation --planifier', () =>
|
|
389
|
+
duPoste(
|
|
390
|
+
principal,
|
|
391
|
+
'npx grillhouse consommation --planifier',
|
|
392
|
+
paquetDuPoste(montee),
|
|
393
|
+
'scripts/consommation.mjs',
|
|
394
|
+
['--planifier']
|
|
395
|
+
)
|
|
396
|
+
);
|
|
388
397
|
echecs.forEach(signaler);
|
|
389
398
|
if (echecs.length > 0) {
|
|
390
399
|
signaler(
|