mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 17: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 {
|
||||
constructor(ctx) {
|
||||
constructor(ctx: Context) {
|
||||
super(ctx, 'vjudge', false);
|
||||
}
|
||||
|
||||
@@ -197,24 +197,24 @@ 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', () => {
|
||||
for (const [k, v] of Object.entries(providers)) {
|
||||
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}`);
|
||||
ctx.plugin(VJudgeService);
|
||||
ctx.inject(['vjudge'], async (c) => {
|
||||
await c.vjudge.start();
|
||||
for (const [k, v] of Object.entries(providers)) {
|
||||
c.vjudge.addProvider(k, v);
|
||||
}
|
||||
if (!working.length) warn('no vjudge worker is working');
|
||||
log(`vjudge working workers: ${working.join(', ')}`);
|
||||
c.inject(['check'], ({ check }) => {
|
||||
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