Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions apps/meteor/app/apps/server/bridges/scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,22 @@ export class AppSchedulerBridge extends SchedulerBridge {
*
* @returns Promise<void>
*/
protected async cancelJobByDataQuery(data: object, appId: string): Promise<void> {
const dataQuery = this.getQueryFromObject('data', data);
this.orch.debugLog(`Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
await this.startScheduler();
const matcher = new RegExp(`_${appId}$`);
try {
await this.scheduler.cancel({ name: { $regex: matcher }, ...dataQuery });
this.orch.debugLog(`Cancelled all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
} catch (e) {
this.orch.debugLog(`Error in Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
console.error(e);
}
protected cancelJobByDataQuery(data: object, appId: string): Promise<number> {
return new Promise(async (resolve, reject) => {
const dataQuery = this.getQueryFromObject('data', data);
this.orch.debugLog(`Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
const matcher = new RegExp(`_${appId}$`);
try {
await this.startScheduler();
const cancel = await this.scheduler.cancel({ name: { $regex: matcher }, ...dataQuery });
this.orch.debugLog(`Cancelled all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
resolve(cancel);
} catch (e) {
this.orch.debugLog(`Error in Canceling all jobs of App ${appId} matching ${JSON.stringify(dataQuery)}`);
console.error(e);
reject(e);
}
});
}

public async startScheduler(): Promise<void> {
Expand Down