Nick: doing on the ci instead
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
name: Check Queues
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '*/5 * * * *'
|
||||||
|
|
||||||
|
env:
|
||||||
|
BULL_AUTH_KEY: ${{ secrets.BULL_AUTH_KEY }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
clean-jobs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Send GET request to check queues
|
||||||
|
run: |
|
||||||
|
response=$(curl --write-out '%{http_code}' --silent --output /dev/null --max-time 180 https://api.firecrawl.dev/admin/${{ secrets.BULL_AUTH_KEY }}/check-queues)
|
||||||
|
if [ "$response" -ne 200 ]; then
|
||||||
|
echo "Failed to check queues. Response: $response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Successfully checked queues. Response: $response"
|
||||||
+15
-2
@@ -10,7 +10,7 @@ import cluster from "cluster";
|
|||||||
import os from "os";
|
import os from "os";
|
||||||
import { Job } from "bull";
|
import { Job } from "bull";
|
||||||
import { sendSlackWebhook } from "./services/alerts/slack";
|
import { sendSlackWebhook } from "./services/alerts/slack";
|
||||||
import { initAlerts } from "./services/alerts";
|
import { checkAlerts } from "./services/alerts";
|
||||||
|
|
||||||
const { createBullBoard } = require("@bull-board/api");
|
const { createBullBoard } = require("@bull-board/api");
|
||||||
const { BullAdapter } = require("@bull-board/api/bullAdapter");
|
const { BullAdapter } = require("@bull-board/api/bullAdapter");
|
||||||
@@ -35,10 +35,10 @@ if (cluster.isMaster) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
initAlerts();
|
|
||||||
} else {
|
} else {
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
||||||
global.isProduction = process.env.IS_PRODUCTION === "true";
|
global.isProduction = process.env.IS_PRODUCTION === "true";
|
||||||
|
|
||||||
app.use(bodyParser.urlencoded({ extended: true }));
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
@@ -246,6 +246,19 @@ if (cluster.isMaster) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get(
|
||||||
|
`/admin/${process.env.BULL_AUTH_KEY}/check-queues`,
|
||||||
|
async (req, res) => {
|
||||||
|
try {
|
||||||
|
await checkAlerts();
|
||||||
|
return res.status(200).send("Alerts initialized");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to initialize alerts:", error);
|
||||||
|
return res.status(500).send("Failed to initialize alerts");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
`/admin/${process.env.BULL_AUTH_KEY}/clean-before-24h-complete-jobs`,
|
`/admin/${process.env.BULL_AUTH_KEY}/clean-before-24h-complete-jobs`,
|
||||||
async (req, res) => {
|
async (req, res) => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { getWebScraperQueue } from "../queue-service";
|
import { getWebScraperQueue } from "../queue-service";
|
||||||
import { sendSlackWebhook } from "./slack";
|
import { sendSlackWebhook } from "./slack";
|
||||||
|
|
||||||
export function initAlerts() {
|
export async function checkAlerts() {
|
||||||
try {
|
try {
|
||||||
if (
|
if (
|
||||||
process.env.SLACK_WEBHOOK_URL &&
|
process.env.SLACK_WEBHOOK_URL &&
|
||||||
@@ -51,7 +51,8 @@ export function initAlerts() {
|
|||||||
await checkWaitingQueue();
|
await checkWaitingQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
setInterval(checkAll, 5 * 60 * 1000); // Run every 5 minutes
|
await checkAll();
|
||||||
|
// setInterval(checkAll, 10000); // Run every
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to initialize alerts:", error);
|
console.error("Failed to initialize alerts:", error);
|
||||||
|
|||||||
Reference in New Issue
Block a user