agent v0.3.17: correction statut Tailscale + overlay de reconnexion pendant l'update
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
|||||||
0.3.16
|
0.3.17
|
||||||
|
|||||||
+3
-5
@@ -214,12 +214,10 @@ func getTailscaleIP() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// isTailscaleReady reports whether tailscaled is running and has successfully
|
// isTailscaleReady reports whether tailscaled is running and has successfully
|
||||||
// joined the tailnet (i.e. it has a Tailscale IP). This is a stronger check
|
// joined the tailnet (i.e. it has a Tailscale IP). It does not rely on
|
||||||
// than isTailscaleRunning which only verifies the process exists.
|
// isTailscaleRunning because tailscaled may have been started by a previous
|
||||||
|
// agent run or externally; the important thing is that the socket responds.
|
||||||
func isTailscaleReady() bool {
|
func isTailscaleReady() bool {
|
||||||
if !isTailscaleRunning() {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
tsCmdMu.Lock()
|
tsCmdMu.Lock()
|
||||||
socket := tsSocket
|
socket := tsSocket
|
||||||
tsCmdMu.Unlock()
|
tsCmdMu.Unlock()
|
||||||
|
|||||||
+58
-15
@@ -608,9 +608,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const ws = new WebSocket('ws://' + location.host + '/ws');
|
let ws;
|
||||||
let currentView = 'activation';
|
let currentView = 'activation';
|
||||||
let studentName = '';
|
let studentName = '';
|
||||||
|
let updateInProgress = false;
|
||||||
const instanceProgress = {}; // instanceId -> { percent, message }
|
const instanceProgress = {}; // instanceId -> { percent, message }
|
||||||
|
|
||||||
const views = {
|
const views = {
|
||||||
@@ -628,23 +629,39 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws.onopen = () => {
|
function connectWebSocket() {
|
||||||
ws.send(JSON.stringify({action: 'check'}));
|
ws = new WebSocket('ws://' + location.host + '/ws');
|
||||||
ws.send(JSON.stringify({action: 'get_status'}));
|
|
||||||
};
|
|
||||||
|
|
||||||
ws.onmessage = (ev) => {
|
ws.onopen = () => {
|
||||||
const msg = JSON.parse(ev.data);
|
if (updateInProgress) {
|
||||||
handleMessage(msg);
|
hideUpdateOverlay();
|
||||||
};
|
updateInProgress = false;
|
||||||
|
}
|
||||||
|
ws.send(JSON.stringify({action: 'check'}));
|
||||||
|
ws.send(JSON.stringify({action: 'get_status'}));
|
||||||
|
};
|
||||||
|
|
||||||
ws.onclose = () => {
|
ws.onmessage = (ev) => {
|
||||||
showView('disconnected');
|
const msg = JSON.parse(ev.data);
|
||||||
};
|
handleMessage(msg);
|
||||||
|
};
|
||||||
|
|
||||||
ws.onerror = () => {
|
ws.onclose = () => {
|
||||||
showView('disconnected');
|
if (updateInProgress) {
|
||||||
};
|
setTimeout(connectWebSocket, 2000);
|
||||||
|
} else {
|
||||||
|
showView('disconnected');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ws.onerror = () => {
|
||||||
|
if (!updateInProgress) {
|
||||||
|
showView('disconnected');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
connectWebSocket();
|
||||||
|
|
||||||
function handleMessage(msg) {
|
function handleMessage(msg) {
|
||||||
switch (msg.action) {
|
switch (msg.action) {
|
||||||
@@ -968,16 +985,31 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
document.getElementById('update-overlay-bar').style.width = pct + '%';
|
||||||
|
document.getElementById('update-overlay-message').textContent = message || 'Mise à jour en cours...';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showUpdateOverlay() {
|
||||||
|
updateInProgress = true;
|
||||||
|
document.getElementById('update-overlay').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideUpdateOverlay() {
|
||||||
|
updateInProgress = false;
|
||||||
|
document.getElementById('update-overlay').classList.add('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function startAgentUpdate() {
|
async function startAgentUpdate() {
|
||||||
|
showUpdateOverlay();
|
||||||
showUpdateProgress('10', 'Préparation de la mise à jour...');
|
showUpdateProgress('10', 'Préparation de la mise à jour...');
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/update', {method: 'POST'});
|
const res = await fetch('/api/update', {method: 'POST'});
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
|
hideUpdateOverlay();
|
||||||
showUpdateProgress('0', 'Erreur ' + res.status);
|
showUpdateProgress('0', 'Erreur ' + res.status);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
hideUpdateOverlay();
|
||||||
showUpdateProgress('0', escapeHtml(err.message));
|
showUpdateProgress('0', escapeHtml(err.message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1044,5 +1076,16 @@
|
|||||||
.replace(/'/g, ''');
|
.replace(/'/g, ''');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Update in progress overlay -->
|
||||||
|
<div id="update-overlay" class="hidden" style="position: fixed; inset: 0; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; z-index: 1000;">
|
||||||
|
<div class="card" style="max-width: 400px; text-align: center;">
|
||||||
|
<div class="service-icon" style="background: var(--info); margin: 0 auto 1rem; width: 48px; height: 48px; font-size: 1.5rem;"><span class="spin">↻</span></div>
|
||||||
|
<h2>Mise à jour en cours</h2>
|
||||||
|
<p class="subtitle">L'agent se redémarre. Cette page se reconnectera automatiquement.</p>
|
||||||
|
<div class="progress-bar"><div id="update-overlay-bar" style="width: 0%"></div></div>
|
||||||
|
<p id="update-overlay-message" class="service-detail" style="margin-top: 0.75rem;">Préparation...</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user