mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 03:32:22 +08:00
Nick: doing on the ci instead
This commit is contained in:
parent
fc3328f3d1
commit
436e8922a7
20
.github/workflows/check-queues.yml
vendored
Normal file
20
.github/workflows/check-queues.yml
vendored
Normal file
|
@ -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"
|
|
@ -10,7 +10,7 @@ import cluster from "cluster";
|
|||
import os from "os";
|
||||
import { Job } from "bull";
|
||||
import { sendSlackWebhook } from "./services/alerts/slack";
|
||||
import { initAlerts } from "./services/alerts";
|
||||
import { checkAlerts } from "./services/alerts";
|
||||
|
||||
const { createBullBoard } = require("@bull-board/api");
|
||||
const { BullAdapter } = require("@bull-board/api/bullAdapter");
|
||||
|
@ -35,10 +35,10 @@ if (cluster.isMaster) {
|
|||
}
|
||||
});
|
||||
|
||||
initAlerts();
|
||||
} else {
|
||||
const app = express();
|
||||
|
||||
|
||||
global.isProduction = process.env.IS_PRODUCTION === "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(
|
||||
`/admin/${process.env.BULL_AUTH_KEY}/clean-before-24h-complete-jobs`,
|
||||
async (req, res) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { getWebScraperQueue } from "../queue-service";
|
||||
import { sendSlackWebhook } from "./slack";
|
||||
|
||||
export function initAlerts() {
|
||||
export async function checkAlerts() {
|
||||
try {
|
||||
if (
|
||||
process.env.SLACK_WEBHOOK_URL &&
|
||||
|
@ -51,7 +51,8 @@ export function initAlerts() {
|
|||
await checkWaitingQueue();
|
||||
};
|
||||
|
||||
setInterval(checkAll, 5 * 60 * 1000); // Run every 5 minutes
|
||||
await checkAll();
|
||||
// setInterval(checkAll, 10000); // Run every
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to initialize alerts:", error);
|
||||
|
|
Loading…
Reference in New Issue
Block a user