From b370169aafca725d17626a0359e00a1c5b86ff0a Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Sun, 1 Dec 2024 22:16:05 -0500 Subject: [PATCH] test --- server/server.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/server/server.js b/server/server.js index 70ad8f1..160314a 100644 --- a/server/server.js +++ b/server/server.js @@ -110,10 +110,10 @@ 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 command + const exec = spawn('sh', ['-c', parsedData.data]); // Use `spawn` to execute the Docker command exec.stdout.on('data', (output) => { - console.log(`[DEBUG] Command output: ${output.toString()}`); + console.log(`[DEBUG] Command output: ${output.toString()}`); // Log the command output peer.write( JSON.stringify({ type: 'dockerOutput', @@ -124,7 +124,7 @@ swarm.on('connection', (peer) => { }); exec.stderr.on('data', (error) => { - console.error(`[ERROR] Command error output: ${error.toString()}`); + console.error(`[ERROR] Command error output: ${error.toString()}`); // Log any errors peer.write( JSON.stringify({ type: 'dockerOutput', @@ -147,8 +147,10 @@ swarm.on('connection', (peer) => { } catch (error) { console.error(`[ERROR] Failed to execute command: ${error.message}`); peer.write( - JSON.stringify({ - error: `Failed to execute command: ${error.message}` + JSON.stringify({ + type: 'dockerOutput', + connectionId: parsedData.connectionId, + data: `[ERROR] Failed to execute command: ${error.message}`, }) ); }