mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: load monitor as plugin
This commit is contained in:
1 parent
ad72f156ac
commit
09f3900eec
3 files changed
+5
-6
No files matched your search
@@ -44,7 +44,7 @@ export async function apply(ctx: Context) {
|
||||
await ctx.root.start();
|
||||
require('../lib/index');
|
||||
await lib(pending, fail, ctx);
|
||||
require('../service/monitor');
|
||||
ctx.plugin(require('../service/monitor'));
|
||||
await service(pending, fail, ctx);
|
||||
await builtinModel(ctx);
|
||||
await model(pending, fail, ctx);
|
||||
|
||||
@@ -649,7 +649,6 @@ export interface HydroService {
|
||||
/** @deprecated */
|
||||
bus: Context,
|
||||
db: typeof import('./service/db').default,
|
||||
monitor: typeof import('./service/monitor'),
|
||||
server: typeof import('./service/server'),
|
||||
storage: typeof import('./service/storage').default,
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { dump } from 'js-yaml';
|
||||
import superagent from 'superagent';
|
||||
import type { StatusUpdate } from '@hydrooj/utils/lib/sysinfo';
|
||||
import * as sysinfo from '@hydrooj/utils/lib/sysinfo';
|
||||
import { Context } from '../context';
|
||||
import { Logger } from '../logger';
|
||||
import * as bus from './bus';
|
||||
import db from './db';
|
||||
@@ -90,8 +91,9 @@ export async function updateJudge(args) {
|
||||
);
|
||||
}
|
||||
|
||||
if (process.env.NODE_APP_INSTANCE === '0') {
|
||||
bus.on('ready', async () => {
|
||||
export function apply(ctx: Context) {
|
||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
||||
ctx.on('app/started', async () => {
|
||||
sysinfo.get().then((info) => {
|
||||
coll.updateOne(
|
||||
{ mid: info.mid, type: 'server' },
|
||||
@@ -103,5 +105,3 @@ if (process.env.NODE_APP_INSTANCE === '0') {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
global.Hydro.service.monitor = { feedback, update, updateJudge };
|
||||
Reference in new issue
Block a user