gpt4 book ai didi

javascript - 如何查找导致pm2重启的错误

转载 作者:行者123 更新时间:2023-12-01 15:04:21 28 4
gpt4 key购买 nike

我正在运行 Node.js puppeteer带有 pm2 的脚本.
保持这个过程稳定很重要。工作 2 天后,我在 pm2 统计信息中看到 2 次重启。
我想找出导致重新启动的原因。在我的错误日志中,我看到 3 个主要错误:

Error: Page crashed (puppeteer )
Error: Quit inactivity timeout (mysql)
or: Timed out after 30000 ms while trying to connect to Chrome! (puppeteer )
这是我的错误日志(我只留下了第一个错误的完整堆栈数据,因为类似的错误具有相同的堆栈)
Error: Page crashed!
at Page._onTargetCrashed (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/puppeteer/lib/Page.js:156:24)
at CDPSession.Page.client.on.event (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/puppeteer/lib/Page.js:132:56)
at CDPSession.emit (events.js:198:13)
at CDPSession._onMessage (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/puppeteer/lib/Connection.js:232:12)
at Connection._onMessage (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/puppeteer/lib/Connection.js:119:19)
at WebSocket.emit (events.js:198:13)
at Receiver.receiverOnMessage (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/ws/lib/websocket.js:720:20)
at Receiver.emit (events.js:198:13)
at Receiver.dataMessage (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/ws/lib/receiver.js:414:14)
at Receiver.getData (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/ws/lib/receiver.js:346:17)

Error: Page crashed!
Error: Page crashed!
Error: Page crashed!
Error: Page crashed!
{ Error: Quit inactivity timeout
at Quit.<anonymous> (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/mysql/lib/protocol/Protocol.js:163:17)
at Quit.emit (events.js:198:13)
at Quit._onTimeout (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/mysql/lib/protocol/sequences/Sequence.js:124:8)
at Timer._onTimeout (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/mysql/lib/protocol/Timer.js:32:23)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
code: 'PROTOCOL_SEQUENCE_TIMEOUT',
fatal: true,
timeout: 30000 }
{ Error: Quit inactivity timeout}
Error: Timed out after 30000 ms while trying to connect to Chrome! The only Chrome revision guaranteed to work is r564778
at Timeout.onTimeout (/home/mysite/domains/mysite.xyz/laravel/robots/node_modules/puppeteer/lib/Launcher.js:296:14)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
Error: Timed out after 30000 ms while trying to connect to Chrome! The only Chrome revision guaranteed to work is r564778
Error: Timed out after 30000 ms while trying to connect to Chrome! The only Chrome revision guaranteed to work is r564778
如何找出导致重新启动的错误?
p.s.:伙计们,我已经在我的问题中发布了日志,我知道如何检查日志!请仔细阅读问题!

最佳答案

要检查进程重启原因的日志,您可以尝试多种方法:

  • pm2 logs fileName.js
  • 为 Node.js 进程注册 exceptionHandlers 以捕获不同的异常。

  • 引用: https://nodejs.org/api/process.html#process_warning_using_uncaughtexception_correctly
  • 根据进程 ID 检查系统中该进程的日志。
  • 关于javascript - 如何查找导致pm2重启的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62612402/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com