Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db連線出錯, 造成解析程序停止 #76

Closed
gibbs-shih opened this issue Aug 6, 2024 · 5 comments
Closed

db連線出錯, 造成解析程序停止 #76

gibbs-shih opened this issue Aug 6, 2024 · 5 comments
Assignees
Labels
5 documentation Improvements or additions to documentation

Comments

@gibbs-shih
Copy link
Contributor

因db連線問題出錯, 造成解析程序停止, 爬蟲程序正常
CleanShot 2024-08-06 at 12 18 23

解決方法:

  1. 重構程式碼, 用db operator通一操作db, 容易除錯(singleton)
  2. 找出可能發生原因的地方做db例外處理
  3. 在可能發生原因的地方throw error, 讓程序crash, pm2自行重啟
@gibbs-shih gibbs-shih added documentation Improvements or additions to documentation 5 labels Aug 6, 2024
@gibbs-shih
Copy link
Contributor Author

Parser error: PrismaClientKnownRequestError: Invalid `prisma.blocks.findFirst()` invocation in /workspace/0729/BAIFA-web-crawling/src/parse/parsing.ts:58:27

Parser error: 出現在 parser 時的 catch error
增加 throw error 將 error return 出來, 以讓 pm2 重新運行
CleanShot 2024-08-07 at 10 47 58

@gibbs-shih
Copy link
Contributor Author

用下面程式碼測試throw error 後, pm2 是否會自動重啟
CleanShot 2024-08-07 at 11 08 15

@gibbs-shih
Copy link
Contributor Author

測試成功pm2自動重啟
CleanShot 2024-08-07 at 11 16 04

@gibbs-shih
Copy link
Contributor Author

此票完成在可能發生原因的地方throw error, 讓程序crash, pm2自行重啟
重構程式碼及例外處理移至 #77

@gibbs-shih
Copy link
Contributor Author

take 3 hr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant