[sandbox] Catch run errors and fetch more often

This commit is contained in:
orosmatthew 2023-05-09 16:51:43 -04:00
parent 2f06247f6d
commit 149037cf7d
2 changed files with 13 additions and 11 deletions

View File

@ -65,13 +65,18 @@ async function cloneAndRun(submissionData: SubmissionGetData) {
); );
await git.checkout(submissionData.submission.commitHash); await git.checkout(submissionData.submission.commitHash);
const problemName = submissionData.submission.problem.pascalName; const problemName = submissionData.submission.problem.pascalName;
const output = await runJava( let output: string;
try {
output = await runJava(
javaBinPath, javaBinPath,
buildDir, buildDir,
join(repoDir, problemName, problemName + '.java'), join(repoDir, problemName, problemName + '.java'),
problemName, problemName,
submissionData.submission.problem.realInput submissionData.submission.problem.realInput
); );
} catch (error) {
output = `[An error occurred while running]\n${error}`;
}
const res = await fetch(urlJoin(adminUrl, 'api/submission'), { const res = await fetch(urlJoin(adminUrl, 'api/submission'), {
method: 'POST', method: 'POST',
@ -128,7 +133,7 @@ async function loop() {
async function run() { async function run() {
while (true) { while (true) {
await loop(); await loop();
await new Promise((resolve) => setTimeout(resolve, 15000)); await new Promise((resolve) => setTimeout(resolve, 10000));
} }
} }

View File

@ -1,8 +1,5 @@
import fs from 'fs-extra';
import { join } from 'path'; import { join } from 'path';
import os from 'os';
import { exec, spawn } from 'child_process'; import { exec, spawn } from 'child_process';
import { error } from 'console';
import util from 'util'; import util from 'util';
const execPromise = util.promisify(exec); const execPromise = util.promisify(exec);