Skip to content

Commit

Permalink
fix worker
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalmishraa committed Aug 29, 2024
1 parent 5e141be commit 81a9cf1
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions apps/worker-compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,9 @@ async function runCommand(command: string, code: string, language: string, expec

const startTime = process.hrtime();
const createdAt = new Date().toISOString();
const timeout = setTimeout(() => {
reject({
stderr: 'Error: Time limit exceeded',
timeTaken: parseFloat((process.hrtime(startTime)[0] + process.hrtime(startTime)[1] / 1e9).toFixed(3)),
memoryUsage: Math.floor(process.memoryUsage().heapUsed / 1024),
created_at: createdAt,
finished_at: new Date().toISOString(),
source_code: code,
language_id: language,
compile_output: '',
exit_code: null,
status_id: 7 // Status ID for time limit exceeded
});
}, 5000); // Set time limit to 5 seconds

exec(command, (error, stdout, stderr) => {
exec(command, { timeout: 5000 }, (error, stdout, stderr) => {

clearTimeout(timeout);
const endTime = process.hrtime(startTime);
const timeTaken = parseFloat((endTime[0] + endTime[1] / 1e9).toFixed(3)); // Convert to seconds and milliseconds till 3 digits
const finishedAt = new Date().toISOString();
Expand Down

0 comments on commit 81a9cf1

Please sign in to comment.