pm2 错误:类型错误:提供的 pid 之一无效

问题描述 投票:0回答:1

如果我使用serve build 80 --spa,那么它运行正常并且站点可以成功访问,但是当我使用sudo pm2serve build 80 --spa或pm2serve build 80 --spa时,我的意思是当我使用pm2来服务时我的reactjs构建,然后它在pm2日志中显示问题并且站点无法访问。这个问题有什么解决办法吗?

ubuntu@ip-172-31-42-194:~/workspace/frontend$ pm2 serve build 80 --spa
[PM2] Starting /usr/local/lib/node_modules/pm2/lib/API/Serve.js in fork_mode (1 instance)
[PM2] Done.
[PM2] Serving /home/ubuntu/workspace/frontend/build on port 80
┌────┬──────────────────────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id │ name                     │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├────┼──────────────────────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0  │ static-page-server-80    │ default     │ 5.3.0   │ fork    │ N/A      │ 0s     │ 0    │ online    │ 0%       │ 0b       │ ubuntu   │ disabled │
└────┴──────────────────────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘
[PM2][WARN] Current process list is not synchronized with saved list. App static-page-server-8080 server differs. Type 'pm2 save' to synchronize.
ubuntu@ip-172-31-42-194:~/workspace/frontend$ pm2 logs
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
/home/ubuntu/.pm2/pm2.log last 15 lines:
PM2        | 2023-09-01T07:55:23: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:55:54: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:55:54: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:56:24: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:56:24: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:56:54: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:56:54: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:57:24: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:57:24: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:57:54: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:57:54: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:58:24: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:58:24: PM2 error: TypeError: One of the pids provided is invalid
PM2        | 2023-09-01T07:58:34: PM2 error: Error caught while calling pidusage
PM2        | 2023-09-01T07:58:34: PM2 error: TypeError: One of the pids provided is invalid

/home/ubuntu/.pm2/logs/static-page-server-80-out.log last 15 lines:
/home/ubuntu/.pm2/logs/static-page-server-80-error.log last 15 lines:

我想使用 pm2 运行我的构建。

reactjs pm2
1个回答
0
投票

我最近遇到了“pm2 错误:TypeError:提供的 PID 之一无效”问题,并通过以下步骤解决了该问题:

  1. 删除node_modules
    rm -rf node_modules
  1. 删除 package-lock.json
    rm package-lock.json
  1. 运行 npm install
    npm install

不知道为什么会出现这个问题,但我尝试重新安装 pm2,然后按照上面给出的步骤,之后我再次启动了我的应用程序。

我在 GitHub 问题讨论中找到了这些步骤。您可以通过此链接阅读原始讨论和更多见解:GitHub Issue #3873

希望这些有帮助:)

© www.soinside.com 2019 - 2024. All rights reserved.