core: 评测机离线后停止未完成的任务分配

fixes #60
pull/61/head
undefined 4 years ago
parent 8018a79418
commit 2ac6cb3745

@ -27,7 +27,7 @@ jobs:
- name: Build
run: yarn build
- name: Lint
run: yarn lint
run: yarn lint:ci
- name: Unit Test
run: yarn jest --runInBand
- name: Report Coverage

@ -9,6 +9,7 @@
"build": "node build/build.js",
"build:watch": "node build/build.js --watch",
"lint": "eslint packages --ext ts --fix",
"lint:ci": "eslint packages --ext ts",
"pub": "node build/publish",
"jest": "node build/jest",
"debug": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug",

@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.20.27",
"version": "2.20.28",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",

@ -112,8 +112,10 @@ export class JudgeFilesDownloadHandler extends Handler {
class JudgeConnectionHandler extends ConnectionHandler {
processing: any = null;
closed = false;
async prepare() {
logger.info('Judge daemon connected from ', this.request.ip);
this.newTask();
}
@ -123,6 +125,7 @@ class JudgeConnectionHandler extends ConnectionHandler {
while (!t) {
// eslint-disable-next-line no-await-in-loop
await sleep(100);
if (this.closed) return;
// eslint-disable-next-line no-await-in-loop
t = await task.getFirst({ type: 'judge' });
}
@ -146,10 +149,12 @@ class JudgeConnectionHandler extends ConnectionHandler {
}
async cleanup() {
logger.info('Judge daemon disconnected from ', this.request.ip);
if (this.processing) {
await record.reset(this.processing.domainId, this.processing.rid, false);
await task.add(this.processing);
}
this.closed = true;
}
}

Loading…
Cancel
Save