core: add disableWorker option

This commit is contained in:
undefined committed 2025-05-14 20:49:07 +08:00
1 parent 526b2768fa
commit 8f0eca6179
1 file changed
+5 -1
+5 -1
View File
@@ -1,3 +1,4 @@
import cac from 'cac';
import moment from 'moment-timezone';
import { sleep } from '@hydrooj/utils';
import { Context, Service } from '../context';
@@ -9,6 +10,8 @@ declare module '../context' {
}
}
const argv = cac().parse();
export default class WorkerService extends Service {
private handlers: Record<string, Function> = {};
consuming = true;
@@ -20,7 +23,8 @@ export default class WorkerService extends Service {
super(ctx, 'worker');
}
async *[Context.init]() {
*[Service.init]() {
if (argv.options.disableWorker) return;
this.consume();
yield () => {
this.consuming = false;