From 9389d41364e5c74c802a3e53fe7b4ffb6a97fab3 Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sun, 1 Dec 2024 22:17:38 -0500 Subject: [PATCH] test --- server/server.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/server.js b/server/server.js index 160314a..4e7e2a4 100644 --- a/server/server.js +++ b/server/server.js @@ -110,10 +110,11 @@ swarm.on('connection', (peer) => { case 'dockerCommand': console.log(`[INFO] Executing Docker CLI command: ${parsedData.data}`); try { - const exec = spawn('sh', ['-c', parsedData.data]); // Use `spawn` to execute the Docker command + const exec = spawn('sh', ['-c', parsedData.data]); // Use spawn to run the Docker command + // Handle stdout (command output) exec.stdout.on('data', (output) => { - console.log(`[DEBUG] Command output: ${output.toString()}`); // Log the command output + console.log(`[DEBUG] Command output: ${output.toString()}`); peer.write( JSON.stringify({ type: 'dockerOutput', @@ -123,8 +124,9 @@ swarm.on('connection', (peer) => { ); }); + // Handle stderr (errors) exec.stderr.on('data', (error) => { - console.error(`[ERROR] Command error output: ${error.toString()}`); // Log any errors + console.error(`[ERROR] Command error output: ${error.toString()}`); peer.write( JSON.stringify({ type: 'dockerOutput', @@ -134,6 +136,7 @@ swarm.on('connection', (peer) => { ); }); + // Handle command completion exec.on('close', (code) => { console.log(`[INFO] Command exited with code: ${code}`); peer.write(