mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: add disableWorker option
This commit is contained in:
1 file changed
+5
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import cac from 'cac';
|
||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
import { sleep } from '@hydrooj/utils';
|
import { sleep } from '@hydrooj/utils';
|
||||||
import { Context, Service } from '../context';
|
import { Context, Service } from '../context';
|
||||||
@@ -9,6 +10,8 @@ declare module '../context' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const argv = cac().parse();
|
||||||
|
|
||||||
export default class WorkerService extends Service {
|
export default class WorkerService extends Service {
|
||||||
private handlers: Record<string, Function> = {};
|
private handlers: Record<string, Function> = {};
|
||||||
consuming = true;
|
consuming = true;
|
||||||
@@ -20,7 +23,8 @@ export default class WorkerService extends Service {
|
|||||||
super(ctx, 'worker');
|
super(ctx, 'worker');
|
||||||
}
|
}
|
||||||
|
|
||||||
async *[Context.init]() {
|
*[Service.init]() {
|
||||||
|
if (argv.options.disableWorker) return;
|
||||||
this.consume();
|
this.consume();
|
||||||
yield () => {
|
yield () => {
|
||||||
this.consuming = false;
|
this.consuming = false;
|
||||||
|
|||||||
Reference in new issue
Block a user