mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
vjudge: fix
This commit is contained in:
1 file changed
+19
-19
@@ -152,7 +152,7 @@ declare module 'hydrooj' {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class VJudgeService extends Service {
|
class VJudgeService extends Service {
|
||||||
constructor(ctx) {
|
constructor(ctx: Context) {
|
||||||
super(ctx, 'vjudge', false);
|
super(ctx, 'vjudge', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,24 +197,24 @@ export const name = 'vjudge';
|
|||||||
export async function apply(ctx: Context) {
|
export async function apply(ctx: Context) {
|
||||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
||||||
if (process.env.HYDRO_CLI) return;
|
if (process.env.HYDRO_CLI) return;
|
||||||
const vjudge = new VJudgeService(ctx);
|
ctx.plugin(VJudgeService);
|
||||||
await vjudge.start();
|
ctx.inject(['vjudge'], async (c) => {
|
||||||
// ctx.on('app/started', () => {
|
await c.vjudge.start();
|
||||||
for (const [k, v] of Object.entries(providers)) {
|
for (const [k, v] of Object.entries(providers)) {
|
||||||
vjudge.addProvider(k, v);
|
c.vjudge.addProvider(k, v);
|
||||||
}
|
|
||||||
// });
|
|
||||||
ctx.provide('vjudge');
|
|
||||||
ctx.vjudge = vjudge;
|
|
||||||
ctx.check.addChecker('Vjudge', async (_ctx, log, warn, error) => {
|
|
||||||
const working = [];
|
|
||||||
const pool = await vjudge.checkStatus(true);
|
|
||||||
for (const [k, v] of Object.entries(pool)) {
|
|
||||||
if (!v.working) error(`vjudge worker ${k}: ${v.error}`);
|
|
||||||
else working.push(k);
|
|
||||||
if (v.status) log(`vjudge worker ${k}: ${v.status}`);
|
|
||||||
}
|
}
|
||||||
if (!working.length) warn('no vjudge worker is working');
|
c.inject(['check'], ({ check }) => {
|
||||||
log(`vjudge working workers: ${working.join(', ')}`);
|
check.addChecker('Vjudge', async (_ctx, log, warn, error) => {
|
||||||
|
const working = [];
|
||||||
|
const pool = await c.vjudge.checkStatus(true);
|
||||||
|
for (const [k, v] of Object.entries(pool)) {
|
||||||
|
if (!v.working) error(`vjudge worker ${k}: ${v.error}`);
|
||||||
|
else working.push(k);
|
||||||
|
if (v.status) log(`vjudge worker ${k}: ${v.status}`);
|
||||||
|
}
|
||||||
|
if (!working.length) warn('no vjudge worker is working');
|
||||||
|
log(`vjudge working workers: ${working.join(', ')}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user