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:
@@ -245,7 +245,7 @@ async function getAddressesForPort53() {
|
||||
|
||||
const addresses = [];
|
||||
for (const phy of physicalDevices) {
|
||||
const [error, output] = await safe(shell.exec(`ip -f inet -j addr show dev ${phy.name} scope global`, {}));
|
||||
const [error, output] = await safe(shell.spawn('ip', ['-f', 'inet', '-j', 'addr', 'show', 'dev', phy.name, 'scope', 'global'], { encoding: 'utf8 '}));
|
||||
if (error) continue;
|
||||
const inet = safe.JSON.parse(output) || [];
|
||||
for (const r of inet) {
|
||||
@@ -650,7 +650,7 @@ async function update(name, memory) {
|
||||
// scale back db containers, if possible. this is retried because updating memory constraints can fail
|
||||
// with failed to write to memory.memsw.limit_in_bytes: write /sys/fs/cgroup/memory/docker/xx/memory.memsw.limit_in_bytes: device or resource busy
|
||||
for (let times = 0; times < 10; times++) {
|
||||
const [error] = await safe(shell.exec(`docker update --memory ${memory} --memory-swap -1 ${name}`, {}));
|
||||
const [error] = await safe(shell.spawn('docker', ['update', '--memory', memory, '--memory-swap', '-1', name], {}));
|
||||
if (!error) return;
|
||||
await timers.setTimeout(60 * 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user