update logs to standard
This commit is contained in:
1 parent
3fc5d7a336
commit
c284eafd63
1 file changed
+17
-7
@@ -1,5 +1,5 @@
|
|||||||
const QUEUE_NAMES = ["uptime", "pagespeed", "hardware"];
|
const QUEUE_NAMES = ["uptime", "pagespeed", "hardware"];
|
||||||
const SERVICE_NAME = "NewJobQueue";
|
const SERVICE_NAME = "JobQueue";
|
||||||
const JOBS_PER_WORKER = 5;
|
const JOBS_PER_WORKER = 5;
|
||||||
const QUEUE_LOOKUP = {
|
const QUEUE_LOOKUP = {
|
||||||
hardware: "hardware",
|
hardware: "hardware",
|
||||||
@@ -63,12 +63,14 @@ class NewJobQueue {
|
|||||||
.filter((monitor) => monitor.isActive)
|
.filter((monitor) => monitor.isActive)
|
||||||
.map(async (monitor) => {
|
.map(async (monitor) => {
|
||||||
try {
|
try {
|
||||||
console.log(`Adding job for monitor: ${monitor._id} (${monitor.type})`);
|
|
||||||
await this.addJob(monitor._id, monitor);
|
await this.addJob(monitor._id, monitor);
|
||||||
console.log(`Successfully added job for monitor: ${monitor._id}`);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to add job for monitor ${monitor._id}:`, error);
|
this.logger.error({
|
||||||
// Don't throw here to allow other jobs to continue
|
message: `Failed to add job for monitor ${monitor._id}:`,
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
method: "initJobQueue",
|
||||||
|
stack: error.stack,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -387,7 +389,11 @@ class NewJobQueue {
|
|||||||
*/
|
*/
|
||||||
async addJob(jobName, monitor) {
|
async addJob(jobName, monitor) {
|
||||||
try {
|
try {
|
||||||
this.logger.info({ message: `Adding job ${monitor?.url ?? "No URL"}` });
|
this.logger.info({
|
||||||
|
message: `Adding job ${monitor?.url ?? "No URL"}`,
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
method: "addJob",
|
||||||
|
});
|
||||||
|
|
||||||
// Find the correct queue
|
// Find the correct queue
|
||||||
|
|
||||||
@@ -545,7 +551,11 @@ class NewJobQueue {
|
|||||||
|
|
||||||
async obliterate() {
|
async obliterate() {
|
||||||
try {
|
try {
|
||||||
this.logger.info({ message: "Attempting to obliterate job queue..." });
|
this.logger.info({
|
||||||
|
message: "Attempting to obliterate job queue...",
|
||||||
|
service: SERVICE_NAME,
|
||||||
|
method: "obliterate",
|
||||||
|
});
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
QUEUE_NAMES.map(async (name) => {
|
QUEUE_NAMES.map(async (name) => {
|
||||||
const queue = this.queues[name];
|
const queue = this.queues[name];
|
||||||
|
|||||||
Reference in new issue
Block a user