mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 17:46:28 +08:00
bug fixes
This commit is contained in:
18 files changed
+90
-72
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user