mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: daemon: 上报系统状态
This commit is contained in:
1 parent
9395ba1a7a
commit
a0b0e59389
6 files changed
+24
-4
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.4.7",
|
"version": "2.4.8",
|
||||||
"os": [
|
"os": [
|
||||||
"linux"
|
"linux"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ parallelism:
|
|||||||
type: number
|
type: number
|
||||||
name: Runner parallelism
|
name: Runner parallelism
|
||||||
default: 2
|
default: 2
|
||||||
|
disable:
|
||||||
|
type: boolean
|
||||||
|
name: Disable builtin judge
|
||||||
|
default: false
|
||||||
langs:
|
langs:
|
||||||
type: textarea
|
type: textarea
|
||||||
name: Language file settings
|
name: Language file settings
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { FormatError, CompileError, SystemError } from '../error';
|
|||||||
import { STATUS_COMPILE_ERROR, STATUS_SYSTEM_ERROR } from '../status';
|
import { STATUS_COMPILE_ERROR, STATUS_SYSTEM_ERROR } from '../status';
|
||||||
import readCases from '../cases';
|
import readCases from '../cases';
|
||||||
import judge from '../judge';
|
import judge from '../judge';
|
||||||
|
import * as sysinfo from '../sysinfo';
|
||||||
|
|
||||||
class JudgeTask {
|
class JudgeTask {
|
||||||
stat: Record<string, Date>;
|
stat: Record<string, Date>;
|
||||||
@@ -258,7 +259,17 @@ export default class Hydro {
|
|||||||
}, 30000);
|
}, 30000);
|
||||||
});
|
});
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
this.ws.once('open', () => { resolve(null); });
|
this.ws.once('open', async () => {
|
||||||
|
if (!this.config.noStatus) {
|
||||||
|
const info = await sysinfo.get();
|
||||||
|
this.ws.send(JSON.stringify({ key: 'status', info }));
|
||||||
|
setInterval(async () => {
|
||||||
|
const [mid, inf] = await sysinfo.update();
|
||||||
|
this.ws.send(JSON.stringify({ key: 'status', info: { mid, ...inf } }));
|
||||||
|
}, 1200000);
|
||||||
|
}
|
||||||
|
resolve(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
log.info(`[${this.config.host}] 已连接`);
|
log.info(`[${this.config.host}] 已连接`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ declare module 'hydrooj/dist/interface' {
|
|||||||
'hydrojudge.testcases_max': number,
|
'hydrojudge.testcases_max': number,
|
||||||
'hydrojudge.total_time_limit': number,
|
'hydrojudge.total_time_limit': number,
|
||||||
'hydrojudge.parallelism': number,
|
'hydrojudge.parallelism': number,
|
||||||
|
'hydrojudge.disable': boolean,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,10 +38,11 @@ async function postInit() {
|
|||||||
const judge = require('./judge');
|
const judge = require('./judge');
|
||||||
const sysinfo = require('./sysinfo');
|
const sysinfo = require('./sysinfo');
|
||||||
|
|
||||||
const { task } = global.Hydro.model;
|
const { task, system } = global.Hydro.model;
|
||||||
const { storage } = global.Hydro.service;
|
const { storage } = global.Hydro.service;
|
||||||
const _judge = global.Hydro.handler.judge as any;
|
const _judge = global.Hydro.handler.judge as any;
|
||||||
|
|
||||||
|
if (system.get('hydrojudge.disable')) return;
|
||||||
const info = await sysinfo.get();
|
const info = await sysinfo.get();
|
||||||
monitor.updateJudger(info);
|
monitor.updateJudger(info);
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.20.4",
|
"version": "2.20.5",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
Route, Handler, Connection, ConnectionHandler, post, Types,
|
Route, Handler, Connection, ConnectionHandler, post, Types,
|
||||||
} from '../service/server';
|
} from '../service/server';
|
||||||
import storage from '../service/storage';
|
import storage from '../service/storage';
|
||||||
|
import { updateJudger } from '../service/monitor';
|
||||||
|
|
||||||
const logger = new Logger('judge');
|
const logger = new Logger('judge');
|
||||||
|
|
||||||
@@ -134,6 +135,8 @@ class JudgeConnectionHandler extends ConnectionHandler {
|
|||||||
await end({ judger: this.user._id, ...msg });
|
await end({ judger: this.user._id, ...msg });
|
||||||
this.processing = null;
|
this.processing = null;
|
||||||
await this.newTask();
|
await this.newTask();
|
||||||
|
} else if (msg.key === 'status') {
|
||||||
|
await updateJudger(msg.info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user