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:
+2
-2
@@ -67,7 +67,7 @@ async function hdparm(file) {
|
||||
}
|
||||
|
||||
async function getSwaps() {
|
||||
const [error, stdout] = await safe(shell.exec('swapon --noheadings --raw --bytes --show=type,size,used,name', {}));
|
||||
const [error, stdout] = await safe(shell.spawn('swapon', ['--noheadings', '--raw', '--bytes', '--show=type,size,used,name'], { encoding: 'utf8' }));
|
||||
if (error) return {};
|
||||
const output = stdout.trim();
|
||||
if (!output) return {}; // no swaps
|
||||
@@ -314,7 +314,7 @@ async function getLogs(unit, options) {
|
||||
}
|
||||
|
||||
async function getBlockDevices() {
|
||||
const result = await shell.exec('lsblk --paths --json --list --fs --output +rota', {});
|
||||
const result = await shell.spawn('lsblk', ['--paths', '--json', '--list', '--fs', '--output', '+rota'], { encoding: 'utf8' });
|
||||
const info = safe.JSON.parse(result);
|
||||
if (!info) throw new BoxError(BoxError.INTERNAL_ERROR, `failed to parse lsblk: ${safe.error.message}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user