mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 18:28:26 +00:00
refactor(sandbox): auto-recreate browser container on config changes (#16254)
This commit is contained in:
committed by
GitHub
parent
31791233d6
commit
1f1fc095a0
@@ -125,6 +125,24 @@ export async function execDocker(args: string[], opts?: ExecDockerOptions) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function readDockerContainerLabel(
|
||||
containerName: string,
|
||||
label: string,
|
||||
): Promise<string | null> {
|
||||
const result = await execDocker(
|
||||
["inspect", "-f", `{{ index .Config.Labels "${label}" }}`, containerName],
|
||||
{ allowFailure: true },
|
||||
);
|
||||
if (result.code !== 0) {
|
||||
return null;
|
||||
}
|
||||
const raw = result.stdout.trim();
|
||||
if (!raw || raw === "<no value>") {
|
||||
return null;
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
export async function readDockerPort(containerName: string, port: number) {
|
||||
const result = await execDocker(["port", containerName, `${port}/tcp`], {
|
||||
allowFailure: true,
|
||||
@@ -341,21 +359,7 @@ async function createSandboxContainer(params: {
|
||||
}
|
||||
|
||||
async function readContainerConfigHash(containerName: string): Promise<string | null> {
|
||||
const readLabel = async (label: string) => {
|
||||
const result = await execDocker(
|
||||
["inspect", "-f", `{{ index .Config.Labels "${label}" }}`, containerName],
|
||||
{ allowFailure: true },
|
||||
);
|
||||
if (result.code !== 0) {
|
||||
return null;
|
||||
}
|
||||
const raw = result.stdout.trim();
|
||||
if (!raw || raw === "<no value>") {
|
||||
return null;
|
||||
}
|
||||
return raw;
|
||||
};
|
||||
return await readLabel("openclaw.configHash");
|
||||
return await readDockerContainerLabel(containerName, "openclaw.configHash");
|
||||
}
|
||||
|
||||
function formatSandboxRecreateHint(params: { scope: SandboxConfig["scope"]; sessionKey: string }) {
|
||||
|
||||
Reference in New Issue
Block a user