Nick: revert trailing comma
This commit is contained in:
@@ -17,15 +17,15 @@ export async function checkAlerts() {
|
||||
const activeJobs = await scrapeQueue.getActiveCount();
|
||||
if (activeJobs > Number(process.env.ALERT_NUM_ACTIVE_JOBS)) {
|
||||
logger.warn(
|
||||
`Alert: Number of active jobs is over ${process.env.ALERT_NUM_ACTIVE_JOBS}. Current active jobs: ${activeJobs}.`
|
||||
`Alert: Number of active jobs is over ${process.env.ALERT_NUM_ACTIVE_JOBS}. Current active jobs: ${activeJobs}.`,
|
||||
);
|
||||
sendSlackWebhook(
|
||||
`Alert: Number of active jobs is over ${process.env.ALERT_NUM_ACTIVE_JOBS}. Current active jobs: ${activeJobs}`,
|
||||
true
|
||||
true,
|
||||
);
|
||||
} else {
|
||||
logger.info(
|
||||
`Number of active jobs is under ${process.env.ALERT_NUM_ACTIVE_JOBS}. Current active jobs: ${activeJobs}`
|
||||
`Number of active jobs is under ${process.env.ALERT_NUM_ACTIVE_JOBS}. Current active jobs: ${activeJobs}`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -39,11 +39,11 @@ export async function checkAlerts() {
|
||||
|
||||
if (waitingJobs > Number(process.env.ALERT_NUM_WAITING_JOBS)) {
|
||||
logger.warn(
|
||||
`Alert: Number of waiting jobs is over ${process.env.ALERT_NUM_WAITING_JOBS}. Current waiting jobs: ${waitingJobs}.`
|
||||
`Alert: Number of waiting jobs is over ${process.env.ALERT_NUM_WAITING_JOBS}. Current waiting jobs: ${waitingJobs}.`,
|
||||
);
|
||||
sendSlackWebhook(
|
||||
`Alert: Number of waiting jobs is over ${process.env.ALERT_NUM_WAITING_JOBS}. Current waiting jobs: ${waitingJobs}. Scale up the number of workers with fly scale count worker=20`,
|
||||
true
|
||||
true,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,18 +4,18 @@ import { logger } from "../../../src/lib/logger";
|
||||
export async function sendSlackWebhook(
|
||||
message: string,
|
||||
alertEveryone: boolean = false,
|
||||
webhookUrl: string = process.env.SLACK_WEBHOOK_URL ?? ""
|
||||
webhookUrl: string = process.env.SLACK_WEBHOOK_URL ?? "",
|
||||
) {
|
||||
const messagePrefix = alertEveryone ? "<!channel> " : "";
|
||||
const payload = {
|
||||
text: `${messagePrefix} ${message}`
|
||||
text: `${messagePrefix} ${message}`,
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await axios.post(webhookUrl, payload, {
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
}
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
logger.info("Webhook sent successfully:", response.data);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user