Introduce backend app for WebSocket terminal sessions and sandbox orchestration.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b1df2607e
commit
91049379f7
22 files changed
+808
-11
No files matched your search
@@ -7,8 +7,8 @@ const MiB = 1024 * 1024;
|
||||
|
||||
/**
|
||||
* The complete container configuration of a sandbox session. Only the
|
||||
* validated session id and expiry come from outside. Keep in sync with
|
||||
* deploy/host/sandbox-flags.sh.
|
||||
* validated session id and expiry come from outside. It must stay identical
|
||||
* to deploy/host/sandbox-flags.sh.
|
||||
*/
|
||||
export function containerSpec(config: SpawnerConfig, sessionId: string, expiresAt: number)
|
||||
{
|
||||
@@ -157,12 +157,22 @@ export class SandboxManager {
|
||||
return container;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills before removing, because Podman's forced removal first sends SIGTERM
|
||||
* and waits ten seconds, which an interactive bash ignores.
|
||||
*/
|
||||
private async remove(containerId: string): Promise<void>
|
||||
{
|
||||
try { await this.docker.call('DELETE', `/containers/${containerId}?force=1`); }
|
||||
await this.tolerateGone(this.docker.call('POST', `/containers/${containerId}/kill?signal=SIGKILL`));
|
||||
await this.tolerateGone(this.docker.call('DELETE', `/containers/${containerId}?force=1`));
|
||||
}
|
||||
|
||||
private async tolerateGone(call: Promise<unknown>): Promise<void>
|
||||
{
|
||||
try { await call; }
|
||||
catch (error)
|
||||
{
|
||||
// A container with AutoRemove may already be gone or in removal.
|
||||
// A container with AutoRemove may already be stopped, gone or in removal.
|
||||
if (error instanceof DockerError && (error.status === 404 || error.status === 409)) return;
|
||||
throw error;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user