fix(recorders): kill stale standby container before on-demand respawn to prevent EADDRINUSE
This commit is contained in:
parent
a096226072
commit
a5aed86349
1 changed files with 17 additions and 0 deletions
|
|
@ -801,6 +801,23 @@ router.post('/:id/start', requireRecorderEdit, async (req, res, next) => {
|
|||
}
|
||||
}
|
||||
|
||||
// If standby HTTP start failed and a stale container_id exists, kill it
|
||||
// before spawning a new one — otherwise the new container gets EADDRINUSE
|
||||
// because the old container is still holding the capture port.
|
||||
if (!containerId && isStandby && recorder.container_id) {
|
||||
console.log(`[recorders] killing stale standby container ${recorder.container_id} before respawn`);
|
||||
try {
|
||||
if (isRemote) {
|
||||
await fetch(`${targetNodeApiUrl}/sidecar/${recorder.container_id}`, {
|
||||
method: 'DELETE',
|
||||
signal: AbortSignal.timeout(10000),
|
||||
}).catch(() => {});
|
||||
} else {
|
||||
await dockerApi('DELETE', `/containers/${recorder.container_id}?force=true`).catch(() => {});
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
if (!containerId && isRemote) {
|
||||
// Remote node: delegate container lifecycle to that node's agent.
|
||||
const sidecarRes = await fetch(`${targetNodeApiUrl}/sidecar/start`, {
|
||||
|
|
|
|||
Loading…
Reference in a new issue