mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-21 22:59:07 +00:00
Refactor queue handling by removing WorkerNotification and updating job configurations in SendReportsToSubscribers
This commit is contained in:
parent
9be007cbda
commit
3809b4585a
@ -14,8 +14,7 @@ import { ExpressRouter } from "../Utils/Express";
|
|||||||
|
|
||||||
export enum QueueName {
|
export enum QueueName {
|
||||||
Workflow = "Workflow",
|
Workflow = "Workflow",
|
||||||
Worker = "Worker",
|
Worker = "Worker"
|
||||||
WorkerNotification = "WorkerNotification",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type QueueJob = Job;
|
export type QueueJob = Job;
|
||||||
|
@ -81,7 +81,7 @@ export default class Recurring extends DatabaseProperty {
|
|||||||
|
|
||||||
if (nextDate.getTime() <= dateNow.getTime()) {
|
if (nextDate.getTime() <= dateNow.getTime()) {
|
||||||
while (nextDate.getTime() <= dateNow.getTime()) {
|
while (nextDate.getTime() <= dateNow.getTime()) {
|
||||||
nextDate = this.getNextDateInterval(startDate, rotation);
|
nextDate = this.getNextDateInterval(nextDate, rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,14 +7,12 @@ import StatusPageService from "Common/Server/Services/StatusPageService";
|
|||||||
import QueryHelper from "Common/Server/Types/Database/QueryHelper";
|
import QueryHelper from "Common/Server/Types/Database/QueryHelper";
|
||||||
import logger from "Common/Server/Utils/Logger";
|
import logger from "Common/Server/Utils/Logger";
|
||||||
import StatusPage from "Common/Models/DatabaseModels/StatusPage";
|
import StatusPage from "Common/Models/DatabaseModels/StatusPage";
|
||||||
import { QueueName } from "Common/Server/Infrastructure/Queue";
|
|
||||||
|
|
||||||
RunCron(
|
RunCron(
|
||||||
"StatusPage:SendReportToSubscribers",
|
"StatusPage:SendReportToSubscribers",
|
||||||
{
|
{
|
||||||
schedule: EVERY_MINUTE,
|
schedule: EVERY_MINUTE,
|
||||||
runOnStartup: false,
|
runOnStartup: false
|
||||||
queueName: QueueName.WorkerNotification,
|
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
// get all scheduled events of all the projects.
|
// get all scheduled events of all the projects.
|
||||||
|
@ -133,25 +133,6 @@ const WorkersFeatureSet: FeatureSet = {
|
|||||||
{ concurrency: 100 },
|
{ concurrency: 100 },
|
||||||
);
|
);
|
||||||
|
|
||||||
// Job process.
|
|
||||||
QueueWorker.getWorker(
|
|
||||||
QueueName.WorkerNotification,
|
|
||||||
async (job: QueueJob) => {
|
|
||||||
const name: string = job.name;
|
|
||||||
|
|
||||||
logger.debug("Running Job: " + name);
|
|
||||||
|
|
||||||
const funcToRun: PromiseVoidFunction =
|
|
||||||
JobDictionary.getJobFunction(name);
|
|
||||||
|
|
||||||
const timeoutInMs: number = JobDictionary.getTimeoutInMs(name);
|
|
||||||
|
|
||||||
if (funcToRun) {
|
|
||||||
await QueueWorker.runJobWithTimeout(timeoutInMs, funcToRun);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ concurrency: 100 },
|
|
||||||
);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("App Init Failed:");
|
logger.error("App Init Failed:");
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user