shell: rework code to use shell.spawn
spawn gives out streams and we have more control over the stdout/stderr buffers. otherwise, we have to provide a max buffer capture size to exec
This commit is contained in:
+5
-4
@@ -70,7 +70,7 @@ async function pruneInfraImages() {
|
||||
const imageIdToPrune = tag === '<none>' ? `${repo}@${digest}` : `${repo}:${tag}`; // untagged, use digest
|
||||
console.log(`pruneInfraImages: removing unused image of ${imageName}: ${imageIdToPrune}`);
|
||||
|
||||
const [error] = await safe(shell.execArgs('docker', [ 'rmi', imageIdToPrune ], {}));
|
||||
const [error] = await safe(shell.spawn('docker', [ 'rmi', imageIdToPrune ], {}));
|
||||
if (error) console.log(`Error removing image ${imageIdToPrune}: ${error.mesage}`);
|
||||
}
|
||||
}
|
||||
@@ -79,16 +79,17 @@ async function pruneInfraImages() {
|
||||
async function pruneVolumes() {
|
||||
debug('pruneVolumes: remove all unused local volumes');
|
||||
|
||||
const [error] = await safe(shell.execArgs('docker', [ 'volume', 'prune', '--all', '--force' ], {}));
|
||||
const [error] = await safe(shell.spawn('docker', [ 'volume', 'prune', '--all', '--force' ], {}));
|
||||
if (error) console.log(`Error pruning volumes: ${error.mesage}`);
|
||||
}
|
||||
|
||||
async function createDockerNetwork() {
|
||||
debug('createDockerNetwork: recreating docker network');
|
||||
|
||||
await shell.exec('docker network rm -f cloudron', {});
|
||||
await shell.spawn('docker', ['network', 'rm', '-f', 'cloudron'], {});
|
||||
// the --ipv6 option will work even in ipv6 is disabled. fd00 is IPv6 ULA
|
||||
await shell.exec(`docker network create --subnet=${constants.DOCKER_IPv4_SUBNET} --ip-range=${constants.DOCKER_IPv4_RANGE} --gateway ${constants.DOCKER_IPv4_GATEWAY} --ipv6 --subnet=fd00:c107:d509::/64 cloudron`, {});
|
||||
await shell.spawn('docker', ['network', 'create', `--subnet=${constants.DOCKER_IPv4_SUBNET}`, `--ip-range=${constants.DOCKER_IPv4_RANGE}`,
|
||||
`--gateway ${constants.DOCKER_IPv4_GATEWAY}`, '--ipv6', '--subnet=fd00:c107:d509::/64', 'cloudron'], {});
|
||||
}
|
||||
|
||||
async function removeAllContainers() {
|
||||
|
||||
Reference in New Issue
Block a user