vjudge: fix

This commit is contained in:
undefined committed 2024-03-09 02:41:03 +08:00
1 parent ac0f425dfc
commit 3d06c7ba55
1 file changed
+10 -10
+10 -10
View File
@@ -152,7 +152,7 @@ declare module 'hydrooj' {
}
class VJudgeService extends Service {
constructor(ctx) {
constructor(ctx: Context) {
super(ctx, 'vjudge', false);
}
@@ -197,18 +197,16 @@ export const name = 'vjudge';
export async function apply(ctx: Context) {
if (process.env.NODE_APP_INSTANCE !== '0') return;
if (process.env.HYDRO_CLI) return;
const vjudge = new VJudgeService(ctx);
await vjudge.start();
// ctx.on('app/started', () => {
ctx.plugin(VJudgeService);
ctx.inject(['vjudge'], async (c) => {
await c.vjudge.start();
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) => {
c.inject(['check'], ({ check }) => {
check.addChecker('Vjudge', async (_ctx, log, warn, error) => {
const working = [];
const pool = await vjudge.checkStatus(true);
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);
@@ -217,4 +215,6 @@ export async function apply(ctx: Context) {
if (!working.length) warn('no vjudge worker is working');
log(`vjudge working workers: ${working.join(', ')}`);
});
});
});
}