[sandbox] Catch run errors and fetch more often
This commit is contained in:
parent
2f06247f6d
commit
149037cf7d
@ -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;
|
||||||
javaBinPath,
|
try {
|
||||||
buildDir,
|
output = await runJava(
|
||||||
join(repoDir, problemName, problemName + '.java'),
|
javaBinPath,
|
||||||
problemName,
|
buildDir,
|
||||||
submissionData.submission.problem.realInput
|
join(repoDir, problemName, problemName + '.java'),
|
||||||
);
|
problemName,
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user