Fix : Deploy bug
Some checks failed
release / build (push) Successful in 23s
release / verify-windows (push) Failing after 1m8s

This commit is contained in:
jeanotx32
2026-08-11 18:41:19 +02:00
parent 80be1e42fc
commit 6f70da56a6
5 changed files with 26 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ commande, les artefacts construits et publiés par Gitea Actions.
┌──────────────────────────┐ ┌───────────────────────────────┐
│ Gitea │ │ Machine du plan de contrôle │
│ ├─ registre d'images ───┼───────►│ docker compose up -d │
│ └─ paquets génériques │ │ → http://control.lan:8080 │
│ └─ paquets génériques │ │ → http://<IP_DU_CONTROLE>:8080 │
│ │ agent.cjs │ └───────────────┬───────────────┘
└─────────┼────────────────┘ │ ws:// (réseau privé)
│ install-agent.sh/.ps1 ┌──────────┴──────────┐
@@ -144,7 +144,7 @@ persiste.
curl -fsSL https://git.jeanbonapp.com/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.sh \
| sudo bash -s -- \
--registry https://git.jeanbonapp.com \
--server ws://control.lan:8080/ws/agent \
--server ws://<IP_DU_CONTROLE>:8080/ws/agent \
--token <JETON_ENROLEMENT> \
--name vm-rec-01 \
--obs-password <MDP_OBS>
@@ -163,7 +163,7 @@ Dans un PowerShell **administrateur**, sur le compte qui lance OBS :
```powershell
& ([scriptblock]::Create((irm 'https://git.jeanbonapp.com/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.ps1'))) `
-Registry 'https://git.jeanbonapp.com' `
-Server 'ws://control.lan:8080/ws/agent' `
-Server 'ws://<IP_DU_CONTROLE>:8080/ws/agent' `
-Token '<JETON_ENROLEMENT>' `
-Name 'vm-rec-02' `
-ObsPassword '<MDP_OBS>'

View File

@@ -70,11 +70,11 @@ docker compose up -d
# Agent Ubuntu
curl -fsSL <gitea>/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.sh \
| sudo bash -s -- --registry <gitea> --server ws://control.lan:8080/ws/agent --token <JETON>
| sudo bash -s -- --registry <gitea> --server ws://<IP_DU_CONTROLE>:8080/ws/agent --token <JETON>
# Agent Windows (PowerShell administrateur)
& ([scriptblock]::Create((irm '<gitea>/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.ps1'))) `
-Registry '<gitea>' -Server 'ws://control.lan:8080/ws/agent' -Token '<JETON>'
-Registry '<gitea>' -Server 'ws://<IP_DU_CONTROLE>:8080/ws/agent' -Token '<JETON>'
```
Les agents ne sont volontairement pas conteneurisés : ils doivent voir l'OBS local et la

View File

@@ -13,7 +13,7 @@
.EXAMPLE
& ([scriptblock]::Create((irm 'https://git.jeanbonapp.com/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.ps1'))) `
-Registry 'https://git.jeanbonapp.com' `
-Server 'ws://control.lan:8080/ws/agent' `
-Server 'ws://<IP_DU_CONTROLE>:8080/ws/agent' `
-Token '<JETON_ENROLEMENT>'
#>

View File

@@ -5,7 +5,7 @@
# curl -fsSL https://git.jeanbonapp.com/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.sh \
# | sudo bash -s -- \
# --registry https://git.jeanbonapp.com \
# --server ws://control.lan:8080/ws/agent \
# --server ws://<IP_DU_CONTROLE>:8080/ws/agent \
# --token <JETON_ENROLEMENT>
#
# Réexécuter le script met à jour le binaire sans toucher à l'identité d'un
@@ -40,7 +40,7 @@ Installe (ou met à jour) l'agent Stream Control sur une VM Linux.
curl -fsSL https://git.jeanbonapp.com/api/packages/jeanbon/generic/stream-control-agent/latest/install-agent.sh \
| sudo bash -s -- \
--registry https://git.jeanbonapp.com \
--server ws://control.lan:8080/ws/agent \
--server ws://<IP_DU_CONTROLE>:8080/ws/agent \
--token <JETON_ENROLEMENT>
Réexécuter le script met à jour le binaire sans toucher à l'identité d'un agent
@@ -215,7 +215,12 @@ systemctl restart "$SERVICE"
# --- Vérification -----------------------------------------------------------
echo
sudo -u "$RUN_USER" AGENT_CONFIG="$CONFIG_FILE" \
# Mêmes variables que l'unité systemd, sinon le diagnostic signale un DISPLAY
# absent que le service, lui, aura bien.
sudo -u "$RUN_USER" \
AGENT_CONFIG="$CONFIG_FILE" \
DISPLAY=":0" \
XAUTHORITY="$USER_HOME/.Xauthority" \
"$(command -v node)" "$INSTALL_DIR/agent.cjs" --check || true
sleep 2

View File

@@ -49,6 +49,7 @@ const watcher = new StreamWatcher(DEFAULT_WATCH_SETTINGS, {
let socket: WebSocket | null = null;
let statusTimer: NodeJS.Timeout | null = null;
let reconnectTimer: NodeJS.Timeout | null = null;
let reconnectDelay = RECONNECT_MIN_MS;
let statusIntervalMs = 2000;
let shuttingDown = false;
@@ -117,7 +118,15 @@ function connect(): void {
function scheduleReconnect(): void {
const delay = reconnectDelay;
reconnectDelay = Math.min(reconnectDelay * 2, RECONNECT_MAX_MS);
setTimeout(connect, delay).unref?.();
// Surtout pas de .unref() ici : pendant une coupure, ce minuteur est la seule
// chose qui maintienne la boucle d'évènements en vie. Déréférencé, le process
// sortirait avec le code 0 au lieu de retenter — la reconnexion ne servirait
// jamais. On garde plutôt la référence pour l'annuler à l'arrêt.
reconnectTimer = setTimeout(() => {
reconnectTimer = null;
connect();
}, delay);
}
// --- Traitement des messages serveur ----------------------------------------
@@ -243,6 +252,8 @@ async function shutdown(signal: string): Promise<void> {
shuttingDown = true;
console.log(`\n${signal} reçu, arrêt de l'agent…`);
stopStatusLoop();
if (reconnectTimer) clearTimeout(reconnectTimer);
reconnectTimer = null;
watcher.stop();
// L'enregistrement OBS en cours n'est volontairement pas interrompu.
await obs.disconnect().catch(() => undefined);