【问题标题】:unable to start pm2 using flask无法使用烧瓶启动 pm2
【发布时间】:2020-08-11 16:42:04
【问题描述】:

根据链接 (https://technopy.com/deploying-a-flask-application-in-production-nginx-gunicorn-and-pm2-html-2/),我按照所有步骤配置 pm2 设置,但服务器也没有启动。 以下是遇到的消息截图。

一旦我输入命令 pm2 list 就没有进程启动。

错误信息是:

2018-07-23T07:23:29.818Z] PM2 log: ===============================================================================
[2018-07-23T07:23:29.818Z] PM2 error: [PM2] Resurrecting PM2
Be sure to have the latest version by doing npm install pm2@latest -g before doing this procedure.
[PM2] Saving current process list...
/usr/local/lib/node_modules/pm2/node_modules/pidusage/lib/procfile.js:26
buf = Buffer.alloc(SIZE)
^
TypeError: Buffer.alloc is not a function
at readUntilEnd (/usr/local/lib/node_modules/pm2/node_modules/pidusage/lib/procfile.js:26:18)
at /usr/local/lib/node_modules/pm2/node_modules/pidusage/lib/procfile.js:67:5
at FSReqWrap.oncomplete (fs.js:82:15)

请提出前进的方向

我试过 pm2 kill 还是不行

仅供参考:

nodejs 版本:4.2.6

pm2 3.0.0

npm 6.1.0

【问题讨论】:

    标签: flask pm2


    【解决方案1】:

    使用以下命令:

    $ export FLASK_APP=hello.py

    $ pm2 开始“烧瓶运行”

    仅供参考:

    Buffer.alloc 需要 Node v4.5.0

    【讨论】:

      【解决方案2】:

      最新版本的 pidusage(依赖于 pm2)因您遇到的错误 (Buffer.alloc) 而被破坏。这是一个已知的问题: https://github.com/soyuka/pidusage/issues/73

      在正式修复发布之前,您也许可以进行临时修复:

      -var Buffer = require('safe-buffer') +var Buffer = require('safe-buffer').Buffer

      即,只需在末尾添加 .Buffer 即可。

      此修复的功劳来自上面链接中的用户“watson”。

      【讨论】:

      • 恢复到版本 pm2@2.10.4。这为我解决了问题。
      【解决方案3】:
      pm2 start "FLASK_ENV=production FLASK_APP=my_code/app.py  flask run -h 0.0.0.0 -p 5001 --with-threads"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-10-18
        • 1970-01-01
        • 1970-01-01
        • 2021-12-26
        • 2021-06-24
        • 1970-01-01
        • 2021-04-11
        • 2015-05-08
        相关资源
        最近更新 更多