mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 03:32:22 +08:00
debug: worker stall check
This commit is contained in:
parent
ef505f8d99
commit
085ac3e71c
|
@ -102,6 +102,8 @@ process.on("SIGTERM", () => {
|
|||
isShuttingDown = true;
|
||||
});
|
||||
|
||||
let cantAcceptConnectionCount = 0;
|
||||
|
||||
const workerFun = async (
|
||||
queue: Queue,
|
||||
processJobInternal: (token: string, job: Job) => Promise<any>
|
||||
|
@ -127,8 +129,19 @@ const workerFun = async (
|
|||
const canAcceptConnection = await monitor.acceptConnection();
|
||||
if (!canAcceptConnection) {
|
||||
console.log("Cant accept connection");
|
||||
cantAcceptConnectionCount++;
|
||||
|
||||
if (cantAcceptConnectionCount >= 25) {
|
||||
logger.error("WORKER STALLED", {
|
||||
cpuUsage: await monitor.checkCpuUsage(),
|
||||
memoryUsage: await monitor.checkMemoryUsage(),
|
||||
});
|
||||
}
|
||||
|
||||
await sleep(cantAcceptConnectionInterval); // more sleep
|
||||
continue;
|
||||
} else {
|
||||
cantAcceptConnectionCount = 0;
|
||||
}
|
||||
|
||||
const job = await worker.getNextJob(token);
|
||||
|
|
|
@ -40,7 +40,7 @@ class SystemMonitor {
|
|||
return SystemMonitor.instance;
|
||||
}
|
||||
|
||||
private async checkMemoryUsage() {
|
||||
public async checkMemoryUsage() {
|
||||
if (IS_KUBERNETES) {
|
||||
return this._checkMemoryUsageKubernetes();
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ class SystemMonitor {
|
|||
return usedMemoryPercentage;
|
||||
}
|
||||
|
||||
private async checkCpuUsage() {
|
||||
public async checkCpuUsage() {
|
||||
if (IS_KUBERNETES) {
|
||||
return this._checkCpuUsageKubernetes();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user