bug fixes

This commit is contained in:
undefined committed 2025-03-28 09:41:45 +08:00
1 parent 56311e1209
commit ec23e81f8e
18 files changed
+90 -72

No files matched your search

+1 -1
View File
@@ -62,7 +62,7 @@ export class MongoService extends Service {
yield () => { this.client.close(); };
this.db = this.client.db(url.database || 'hydro');
await bus.parallel('database/connect', this.db);
this.ctx.setInterval(() => this.fixExpireAfter(), Time.hour);
yield this.ctx.setInterval(() => this.fixExpireAfter(), Time.hour);
}
public collection<K extends keyof Collections>(c: K) {
+9 -12
View File
@@ -98,17 +98,14 @@ export async function updateJudge(args) {
);
}
export function apply(ctx: Context) {
export async 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' },
{ $set: { ...info, updateAt: new Date(), type: 'server' } },
{ upsert: true },
);
feedback();
setInterval(update, 1800 * 1000);
});
});
const info = await sysinfo.get();
coll.updateOne(
{ mid: info.mid, type: 'server' },
{ $set: { ...info, updateAt: new Date(), type: 'server' } },
{ upsert: true },
);
feedback();
return ctx.setInterval(update, 1800 * 1000); // eslint-disable-line
}
+7 -5
View File
@@ -18,7 +18,14 @@ export default class WorkerService extends Service {
constructor(ctx: Context) {
super(ctx, 'worker');
}
async *[Context.init]() {
this.consume();
yield () => {
this.consuming = false;
return this.promise;
};
}
async getFirst() {
@@ -79,9 +86,4 @@ export default class WorkerService extends Service {
};
});
}
public async stop() {
this.consuming = false;
await this.promise;
}
}