Make a container action tell the truth about what happened

The response was discarded, so a refused stop looked like a completed one, and the payload the
card redraws from is cached for 300s with no invalidation — the container carried on showing as
running until the once-a-minute writer caught up. Stop now confirms; start still does not.
This commit is contained in:
Gmer4Lfe
2026-08-07 10:20:11 -04:00
parent fb50f94ed8
commit b445ddc2c8
4 changed files with 52 additions and 4 deletions
+8
View File
@@ -127,8 +127,15 @@ if ($check !== $name) {
echo json_encode(['ok' => false, 'error' => 'Container not found']); exit;
}
// Every arm below drops the monitor cache once the container state has actually changed. That
// payload carries the container list the dashboard draws, is served with a 300s window, and is
// otherwise only rewritten by the once-a-minute cache writer — so without this the operator stops
// a container, watches the card, and sees it running for up to a minute with no hint as to why.
// Cleared after the command rather than before, so a failed action does not throw away a payload
// that is still accurate.
if ($action === 'start' || $action === 'stop') {
exec(($action === 'start' ? 'docker start' : 'docker stop') . ' ' . escapeshellarg($name) . ' 2>&1', $out, $rc);
if ($rc === 0) vv_cache_clear('monitor');
echo json_encode(['ok' => $rc === 0, 'output' => implode("\n", $out)]); exit;
}
@@ -142,6 +149,7 @@ if ($action === 'restart') {
$out = array_merge($o1, $o2);
$rc = ($rc1 === 0 && $rc2 === 0) ? 0 : 1;
}
if ($rc === 0) vv_cache_clear('monitor');
echo json_encode(['ok' => $rc === 0, 'output' => implode("\n", $out)]); exit;
}