mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +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;
|
host: string;
|
||||||
request: any;
|
request: any;
|
||||||
ws: WebSocket;
|
ws: WebSocket;
|
||||||
tag: any;
|
|
||||||
type: any;
|
|
||||||
domainId: string;
|
domainId: string;
|
||||||
pid: string;
|
pid: string;
|
||||||
rid: string;
|
rid: string;
|
||||||
@@ -59,8 +57,6 @@ class JudgeTask {
|
|||||||
this.next = this.next.bind(this);
|
this.next = this.next.bind(this);
|
||||||
this.end = this.end.bind(this);
|
this.end = this.end.bind(this);
|
||||||
this.stat.handle = new Date();
|
this.stat.handle = new Date();
|
||||||
this.tag = this.request.tag;
|
|
||||||
this.type = this.request.type;
|
|
||||||
this.domainId = this.request.pdomain;
|
this.domainId = this.request.pdomain;
|
||||||
this.pid = this.request.pid.toString();
|
this.pid = this.request.pid.toString();
|
||||||
this.rid = this.request.rid;
|
this.rid = this.request.rid;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.34.3",
|
"version": "2.34.4",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ class WorkerService implements BaseService {
|
|||||||
async (doc) => {
|
async (doc) => {
|
||||||
try {
|
try {
|
||||||
logger.debug('Worker task: %o', doc);
|
logger.debug('Worker task: %o', doc);
|
||||||
|
const start = Date.now();
|
||||||
await this.handlers[doc.subType](doc);
|
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) {
|
} catch (e) {
|
||||||
logger.error('Worker task fail: ', e);
|
logger.error('Worker task fail: ', e);
|
||||||
logger.error('%o', doc);
|
logger.error('%o', doc);
|
||||||
|
|||||||
@@ -50,7 +50,12 @@ class MongoService implements BaseService {
|
|||||||
|
|
||||||
public async ensureIndexes<T>(coll: Collection<T>, ...args: IndexSpecification[]) {
|
public async ensureIndexes<T>(coll: Collection<T>, ...args: IndexSpecification[]) {
|
||||||
if (process.env.NODE_APP_INSTANCE !== '0') return;
|
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) {
|
for (const index of args) {
|
||||||
const i = existed.find(t => t.name == index.name || JSON.stringify(t.key) == JSON.stringify(index.key));
|
const i = existed.find(t => t.name == index.name || JSON.stringify(t.key) == JSON.stringify(index.key));
|
||||||
if (!i) {
|
if (!i) {
|
||||||
|
|||||||
Reference in new issue
Block a user