diff --git a/infra/sandbox/src/services/container-service.ts b/infra/sandbox/src/services/container-service.ts index 9cd29d65..21eb9402 100644 --- a/infra/sandbox/src/services/container-service.ts +++ b/infra/sandbox/src/services/container-service.ts @@ -586,6 +586,12 @@ class ContainerService { } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { + containerId: container.id, + }); + }); + stream.on("end", () => { resolve({ stdout, stderr }); }); diff --git a/infra/sandbox/src/services/dependency-service.ts b/infra/sandbox/src/services/dependency-service.ts index c20a1038..3a8c2fee 100644 --- a/infra/sandbox/src/services/dependency-service.ts +++ b/infra/sandbox/src/services/dependency-service.ts @@ -72,6 +72,10 @@ class NodePackageHandler implements DependencyHandler { } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { position: 'NodePackageHandler', containerId: container.id }); + }); + stream.on("end", async () => { try { const inspectData = await exec.inspect(); @@ -186,6 +190,10 @@ class PythonPackageHandler implements DependencyHandler { } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { position: 'PythonPackageHandler', containerId: container.id }); + }); + stream.on("end", async () => { try { const inspectData = await exec.inspect(); diff --git a/infra/sandbox/src/services/execution-service.ts b/infra/sandbox/src/services/execution-service.ts index 2c6b8912..99989dd9 100644 --- a/infra/sandbox/src/services/execution-service.ts +++ b/infra/sandbox/src/services/execution-service.ts @@ -384,6 +384,12 @@ class ExecutionService { } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { + containerId: container.id, + }); + }); + stream.on("end", async () => { try { const inspectData = await exec.inspect(); @@ -418,6 +424,7 @@ class ExecutionService { }); }); } + } export default new ExecutionService(); diff --git a/infra/sandbox/src/services/file-service.ts b/infra/sandbox/src/services/file-service.ts index f443138b..192a1657 100644 --- a/infra/sandbox/src/services/file-service.ts +++ b/infra/sandbox/src/services/file-service.ts @@ -8,6 +8,7 @@ import { ApiError } from "../middleware/error-handler"; import { SandboxFiles } from "../types"; import gitService from "./git-service"; import dockerConfig from "./docker-config"; +import tar from 'tar-stream' // 固定工作目录,所有代码都存放在这里,由Git管理版本 const WORK_DIR = "/home/sandbox"; @@ -363,7 +364,6 @@ class FileService { }); // Extract the zip file from the tar archive - const tar = require("tar-stream"); const extract = tar.extract(); // Use promise to properly handle async extraction @@ -376,6 +376,7 @@ class FileService { stream.on("data", (chunk: Buffer) => { chunks.push(chunk); + logger.info(`${chunk.toString()}`, { position: 'FileService', containerId: container.id }); }); stream.on("end", () => { @@ -501,6 +502,10 @@ class FileService { } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { position: 'FileService', containerId: container.id }); + }); + stream.on("end", () => { resolve({ stdout, stderr }); }); @@ -530,8 +535,7 @@ class FileService { // Read the file content const content = fs.readFileSync(localPath); - // Create a tar stream with the file - const pack = require("tar-stream").pack(); + const pack = tar.pack(); // Add file to the tar stream const fileName = path.basename(containerPath); diff --git a/infra/sandbox/src/services/git-service.ts b/infra/sandbox/src/services/git-service.ts index 57370159..ce664ab1 100644 --- a/infra/sandbox/src/services/git-service.ts +++ b/infra/sandbox/src/services/git-service.ts @@ -597,6 +597,10 @@ Thumbs.db } ); + stream.on("data", (chunk: Buffer) => { + logger.info(`${chunk.toString()}`, { position: 'GitService', containerId: container.id }); + }); + stream.on("end", () => { resolve({ stdout, stderr }); });