Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Merge branch 'main' into nsc/admin-router

Nicolas10e80f00cf4a
diff --cc apps/api/src/index.ts
index 69433d6b1,9e2305217..3fba86f8a
--- a/apps/api/src/index.ts
+++ b/apps/api/src/index.ts
@@@ -7,8 -7,13 +7,9 @@@ import { v0Router } from "./routes/v0"
import { initSDK } from "@hyperdx/node-opentelemetry";
import cluster from "cluster";
import os from "os";
-import { Job } from "bull";
-import { sendSlackWebhook } from "./services/alerts/slack";
-import { checkAlerts } from "./services/alerts";
-import Redis from "ioredis";
-import { redisRateLimitClient } from "./services/rate-limiter";
import { Logger } from "./lib/logger";
+import { adminRouter } from "./routes/admin";
+ import { ScrapeEvents } from "./lib/scrape-events";
const { createBullBoard } = require("@bull-board/api");
const { BullAdapter } = require("@bull-board/api/bullAdapter");
@@@ -166,5 -254,84 +167,14 @@@ if (cluster.isMaster)
res.send({ isProduction: global.isProduction });
});
- app.get(
- `/admin/${process.env.BULL_AUTH_KEY}/redis-health`,
- async (req, res) => {
- try {
- const queueRedis = new Redis(process.env.REDIS_URL);
-
- const testKey = "test";
- const testValue = "test";
-
- // Test queueRedis
- let queueRedisHealth;
- try {
- await queueRedis.set(testKey, testValue);
- queueRedisHealth = await queueRedis.get(testKey);
- await queueRedis.del(testKey);
- } catch (error) {
- Logger.error(`queueRedis health check failed: ${error}`);
- queueRedisHealth = null;
- }
-
- // Test redisRateLimitClient
- let redisRateLimitHealth;
- try {
- await redisRateLimitClient.set(testKey, testValue);
- redisRateLimitHealth = await redisRateLimitClient.get(testKey);
- await redisRateLimitClient.del(testKey);
- } catch (error) {
- Logger.error(`redisRateLimitClient health check failed: ${error}`);
- redisRateLimitHealth = null;
- }
-
- const healthStatus = {
- queueRedis: queueRedisHealth === testValue ? "healthy" : "unhealthy",
- redisRateLimitClient:
- redisRateLimitHealth === testValue ? "healthy" : "unhealthy",
- };
-
- if (
- healthStatus.queueRedis === "healthy" &&
- healthStatus.redisRateLimitClient === "healthy"
- ) {
- Logger.info("Both Redis instances are healthy");
- return res
- .status(200)
- .json({ status: "healthy", details: healthStatus });
- } else {
- Logger.info(`Redis instances health check: ${JSON.stringify(healthStatus)}`);
- await sendSlackWebhook(
- `[REDIS DOWN] Redis instances health check: ${JSON.stringify(
- healthStatus
- )}`,
- true
- );
- return res
- .status(500)
- .json({ status: "unhealthy", details: healthStatus });
- }
- } catch (error) {
- Logger.error(`Redis health check failed: ${error}`);
- await sendSlackWebhook(
- `[REDIS DOWN] Redis instances health check: ${error.message}`,
- true
- );
- return res
- .status(500)
- .json({ status: "unhealthy", message: error.message });
- }
- }
- );
-
Logger.info(`Worker ${process.pid} started`);
}
+
+ const wsq = getWebScraperQueue();
+
+ wsq.on("waiting", j => ScrapeEvents.logJobEvent(j, "waiting"));
+ wsq.on("active", j => ScrapeEvents.logJobEvent(j, "active"));
+ wsq.on("completed", j => ScrapeEvents.logJobEvent(j, "completed"));
+ wsq.on("paused", j => ScrapeEvents.logJobEvent(j, "paused"));
+ wsq.on("resumed", j => ScrapeEvents.logJobEvent(j, "resumed"));
+ wsq.on("removed", j => ScrapeEvents.logJobEvent(j, "removed"));