bug fixes

This commit is contained in:
undefined committed 2024-06-27 03:58:29 +08:00
1 parent 16b6f53653
commit 84f7d5dc80
20 files changed
+43 -35

No files matched your search

+1 -1
View File
@@ -99,7 +99,7 @@ export async function postInit(ctx) {
function collectCompilerInfo() {
const coll = db.collection('status');
compilerVersions(langs).then((compilers) => coll.updateOne(
{ mid: info.mid, type: 'judge' },
{ mid: info.mid, type: 'server' },
{ $set: { compilers } },
{ upsert: true },
)).catch((e) => logger.error(e));
+6 -1
View File
@@ -175,6 +175,7 @@ export default class Hydro implements Session {
? JSON.stringify({ key: 'config', ...config })
: '{"key":"ping"}';
let compilers = {};
let compilerVersionCallback = () => { };
this.ws.on('message', (data) => {
if (data.toString() === 'ping') {
this.ws.send('pong');
@@ -185,6 +186,7 @@ export default class Hydro implements Session {
this.language = request.language;
compilerVersions(this.language).then((res) => {
compilers = res;
compilerVersionCallback();
});
}
if (request.task) queue.add(() => new JudgeTask(this, request.task).handle().catch((e) => log.error(e)));
@@ -203,7 +205,10 @@ export default class Hydro implements Session {
this.ws.send('{"key":"start"}');
if (!this.config.noStatus) {
const info = await sysinfo.get();
this.ws.send(JSON.stringify({ key: 'status', info: { ...info, compilers } }));
this.ws.send(JSON.stringify({ key: 'status', info: { ...info } }));
compilerVersionCallback = () => {
this.ws.send(JSON.stringify({ key: 'status', info: { ...info, compilers } }));
};
setInterval(async () => {
const [mid, inf] = await sysinfo.update();
this.ws.send(JSON.stringify({ key: 'status', info: { mid, ...inf, compilers } }));