mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core: fix index creation (#197)
This commit is contained in:
1 parent
62dbd0beb8
commit
f5c63e02ce
4 files changed
+10
-6
No files matched your search
@@ -28,8 +28,6 @@ class JudgeTask {
|
||||
host: string;
|
||||
request: any;
|
||||
ws: WebSocket;
|
||||
tag: any;
|
||||
type: any;
|
||||
domainId: string;
|
||||
pid: string;
|
||||
rid: string;
|
||||
@@ -59,8 +57,6 @@ class JudgeTask {
|
||||
this.next = this.next.bind(this);
|
||||
this.end = this.end.bind(this);
|
||||
this.stat.handle = new Date();
|
||||
this.tag = this.request.tag;
|
||||
this.type = this.request.type;
|
||||
this.domainId = this.request.pdomain;
|
||||
this.pid = this.request.pid.toString();
|
||||
this.rid = this.request.rid;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.34.3",
|
||||
"version": "2.34.4",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "src/loader",
|
||||
"module": "src/loader",
|
||||
|
||||
@@ -69,7 +69,10 @@ class WorkerService implements BaseService {
|
||||
async (doc) => {
|
||||
try {
|
||||
logger.debug('Worker task: %o', doc);
|
||||
const start = Date.now();
|
||||
await this.handlers[doc.subType](doc);
|
||||
const spent = Date.now() - start;
|
||||
if (spent > 500) logger.warn('Slow worker task (%d ms): %s', spent, doc);
|
||||
} catch (e) {
|
||||
logger.error('Worker task fail: ', e);
|
||||
logger.error('%o', doc);
|
||||
|
||||
@@ -50,7 +50,12 @@ class MongoService implements BaseService {
|
||||
|
||||
public async ensureIndexes<T>(coll: Collection<T>, ...args: IndexSpecification[]) {
|
||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
||||
const existed = await coll.listIndexes().toArray();
|
||||
let existed: any[];
|
||||
try {
|
||||
existed = await coll.listIndexes().toArray();
|
||||
} catch (e) {
|
||||
existed = [];
|
||||
}
|
||||
for (const index of args) {
|
||||
const i = existed.find(t => t.name == index.name || JSON.stringify(t.key) == JSON.stringify(index.key));
|
||||
if (!i) {
|
||||
|
||||
Reference in new issue
Block a user