mirror of
https://git.mirrors.martin98.com/https://github.com/jina-ai/reader
synced 2025-08-14 21:05:56 +08:00
fix: tweak health check
This commit is contained in:
parent
528b3e5fed
commit
55b954ffeb
@ -151,21 +151,24 @@ export class PuppeteerControl extends AsyncService {
|
|||||||
|
|
||||||
@maxConcurrency(1)
|
@maxConcurrency(1)
|
||||||
async healthCheck() {
|
async healthCheck() {
|
||||||
const healthyPage = await Promise.race([this.pagePool.acquire(3), delay(60_000).then(() => null)]).catch((err) => {
|
this.pagePool.max += 1;
|
||||||
this.logger.error(`Health check failed`, { err: marshalErrorLike(err) });
|
const healthyPage = await this.pagePool.acquire(3).catch((err) => {
|
||||||
|
this.logger.warn(`Health check failed`, { err: marshalErrorLike(err) });
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
this.pagePool.max -= 1;
|
||||||
|
|
||||||
if (healthyPage) {
|
if (healthyPage) {
|
||||||
this.pagePool.release(healthyPage);
|
this.pagePool.release(healthyPage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.warn(`Health check failed, trying to clean up.`);
|
this.logger.warn(`Trying to clean up...`);
|
||||||
await this.pagePool.clear();
|
await this.pagePool.clear();
|
||||||
this.browser.process()?.kill('SIGKILL');
|
this.browser.process()?.kill('SIGKILL');
|
||||||
Reflect.deleteProperty(this, 'browser');
|
Reflect.deleteProperty(this, 'browser');
|
||||||
this.emit('crippled');
|
this.emit('crippled');
|
||||||
|
this.logger.warn(`Browser killed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async newPage() {
|
async newPage() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user