mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ci: fix jest not exiting
This commit is contained in:
1 parent
75429bb43b
commit
1f6c0893ca
3 files changed
+8
-1
No files matched your search
@@ -36,7 +36,7 @@ jobs:
|
|||||||
- name: Lint
|
- name: Lint
|
||||||
run: yarn lint:ci
|
run: yarn lint:ci
|
||||||
- name: Unit Test
|
- name: Unit Test
|
||||||
run: yarn jest --runInBand
|
run: yarn jest
|
||||||
- name: Report Coverage
|
- name: Report Coverage
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { FilterQuery, ObjectID } from 'mongodb';
|
|||||||
import { BaseService, Task } from '../interface';
|
import { BaseService, Task } from '../interface';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import db from '../service/db';
|
import db from '../service/db';
|
||||||
|
import * as bus from '../service/bus';
|
||||||
|
|
||||||
const logger = new Logger('model/task');
|
const logger = new Logger('model/task');
|
||||||
const coll = db.collection('task');
|
const coll = db.collection('task');
|
||||||
@@ -31,6 +32,8 @@ class Consumer {
|
|||||||
this.consuming = true;
|
this.consuming = true;
|
||||||
this.get = this.get.bind(this);
|
this.get = this.get.bind(this);
|
||||||
this.get();
|
this.get();
|
||||||
|
this.destory = this.destory.bind(this);
|
||||||
|
bus.on('app/exit', this.destory);
|
||||||
}
|
}
|
||||||
|
|
||||||
async get() {
|
async get() {
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
import cluster from 'cluster';
|
||||||
import 'hydrooj/src/loader';
|
import 'hydrooj/src/loader';
|
||||||
|
import * as bus from 'hydrooj/src/service/bus';
|
||||||
|
|
||||||
jest.mock('hydrooj/src/service/db');
|
jest.mock('hydrooj/src/service/db');
|
||||||
|
|
||||||
@@ -20,4 +22,6 @@ export async function connect() {
|
|||||||
export async function dispose() {
|
export async function dispose() {
|
||||||
const db = require('hydrooj/src/service/db');
|
const db = require('hydrooj/src/service/db');
|
||||||
await db.stop();
|
await db.stop();
|
||||||
|
bus.emit('app/exit');
|
||||||
|
for (const key in cluster.workers) cluster.workers[key].destroy('SIGINT');
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user