优化 Chromium,更新软件包

This commit is contained in:
🌌 2024-03-08 09:48:18 +08:00
parent c815d50be8
commit 94074110d4
2 changed files with 30 additions and 35 deletions

View File

@ -19,32 +19,32 @@
"dependencies": {
"art-template": "^4.13.2",
"chalk": "^5.3.0",
"chokidar": "^3.5.3",
"https-proxy-agent": "7.0.2",
"icqq": "^0.6.5",
"image-size": "^1.0.2",
"inquirer": "^9.2.12",
"chokidar": "^3.6.0",
"https-proxy-agent": "7.0.4",
"icqq": "*",
"image-size": "^1.1.1",
"inquirer": "^9.2.15",
"lodash": "^4.17.21",
"log4js": "^6.9.1",
"md5": "^2.3.0",
"moment": "^2.29.4",
"moment": "^2.30.1",
"node-fetch": "^3.3.2",
"node-schedule": "^2.1.1",
"oicq": "^2.3.1",
"pm2": "^5.3.0",
"puppeteer": "^21.5.2",
"redis": "^4.6.11",
"sequelize": "^6.35.1",
"oicq": "*",
"pm2": "^5.3.1",
"puppeteer": "*",
"redis": "^4.6.13",
"sequelize": "^6.37.1",
"sqlite3": "5.1.6",
"yaml": "^2.3.4"
"yaml": "^2.4.1"
},
"devDependencies": {
"eslint": "^8.55.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-promise": "^6.1.1",
"express": "^4.18.2",
"express": "^4.18.3",
"express-art-template": "^1.0.1"
},
"imports": {

View File

@ -110,15 +110,7 @@ export default class Puppeteer extends Renderer {
}
/** 监听Chromium实例是否断开 */
this.browser.on("disconnected", async () => {
logger.info("puppeteer Chromium 实例关闭")
try {
await this.browser.close()
} catch (err) {
logger.error("puppeteer Chromium 关闭错误", err)
}
this.browser = false
})
this.browser.on("disconnected", () => this.restart(true))
return this.browser
}
@ -286,16 +278,19 @@ export default class Puppeteer extends Renderer {
/** 重启 */
restart(force = false) {
/** 截图超过重启数时,自动关闭重启浏览器,避免生成速度越来越慢 */
if (!this.browser) return
if (!this.browser?.close || this.lock) return
if (!force) if (this.renderNum % this.restartNum !== 0 || this.shoting.length > 0) return
setTimeout(async () => {
logger.info(`puppeteer Chromium ${force ? "强制" : ""}关闭重启...`)
this.stop(this.browser)
this.browser = false
return this.browserInit()
}
async stop(browser) {
try {
await this.browser.close()
await browser.close()
} catch (err) {
logger.error("puppeteer Chromium 关闭错误", err)
}
this.browser = false
}, 100)
}
}