mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-29 05:09:26 -06:00
add update job method
This commit is contained in:
@@ -62,10 +62,9 @@ class PulseQueue {
|
||||
service: SERVICE_NAME,
|
||||
method: "deleteJob",
|
||||
});
|
||||
const result = await this.pulse.cancel({
|
||||
await this.pulse.cancel({
|
||||
"data.monitor._id": monitor._id,
|
||||
});
|
||||
console.log(result);
|
||||
};
|
||||
|
||||
pauseJob = async (monitor) => {
|
||||
@@ -100,6 +99,22 @@ class PulseQueue {
|
||||
});
|
||||
};
|
||||
|
||||
updateJob = async (monitor) => {
|
||||
const jobs = await this.pulse.jobs({
|
||||
"data.monitor._id": monitor._id,
|
||||
});
|
||||
|
||||
const job = jobs[0];
|
||||
if (!job) {
|
||||
throw new Error("Job not found");
|
||||
}
|
||||
|
||||
const intervalInSeconds = monitor.interval / 1000;
|
||||
job.repeatEvery(`${intervalInSeconds} seconds`);
|
||||
job.attrs.data.monitor = monitor;
|
||||
await job.save();
|
||||
};
|
||||
|
||||
shutdown = async () => {
|
||||
this.logger.info({
|
||||
message: "Shutting down JobQueue",
|
||||
|
||||
Reference in New Issue
Block a user