mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix websocket event push
This commit is contained in:
1 parent
518915ceab
commit
f834d9ca87
5 files changed
+5
-5
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { hostname } from 'os';
|
||||
import cac from 'cac';
|
||||
import { FilterQuery, ObjectID } from 'mongodb';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { sleep } from '@hydrooj/utils/lib/utils';
|
||||
@@ -11,6 +12,7 @@ import db from '../service/db';
|
||||
const logger = new Logger('model/task');
|
||||
const coll = db.collection('task');
|
||||
const collEvent = db.collection('event');
|
||||
const argv = cac().parse();
|
||||
|
||||
async function getFirst(query: FilterQuery<Task>) {
|
||||
if (process.env.CI) return null;
|
||||
@@ -133,6 +135,7 @@ export async function apply(ctx: Context) {
|
||||
{ expire: { $gt: new Date() }, ack: { $nin: [id] } },
|
||||
{ $push: { ack: id } },
|
||||
);
|
||||
if (argv.options.showEvent) logger.info('Event: %o', res.value);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await (res.value ? handleEvent(res.value) : sleep(500));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user