【问题标题】:Nodejs app not using Procfile but npm start insteadNodejs 应用程序不使用 Procfile,而是使用 npm start
【发布时间】:2020-09-07 03:06:53
【问题描述】:

我在 Heroku 上运行一个 nodejs express 服务器。我在我的应用程序根目录中定义了一个 Procfile,其中包含:

web:node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js

但是,当我使用 heroku logs -a my-app --tail 时,我注意到我的应用程序是使用 npm start 启动的,这只是 node server.js 而不是我放入 Procfile 中的内容。这是日志:

2020-05-20T16:28:35.000000+00:00 app[api]: Build succeeded
2020-05-20T16:28:36.489864+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-05-20T16:28:36.575077+00:00 heroku[web.1]: Process exited with status 143
2020-05-20T16:28:37.695081+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-20T16:28:40.709631+00:00 app[web.1]: 
2020-05-20T16:28:40.709647+00:00 app[web.1]: > my-app@0.0.1 start /app
2020-05-20T16:28:40.709648+00:00 app[web.1]: > node server.js
2020-05-20T16:28:40.709648+00:00 app[web.1]: 

据我从 Heroku 的文档中了解到,npm start 仅应在未检测到 Procfile 时使用。我在这里错过了什么?

【问题讨论】:

    标签: node.js express heroku procfile heroku-nodejs


    【解决方案1】:

    问题是我的进程名称和Procfile 中的命令之间没有空格。现在这对我有用:

    web: node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js
    

    这是heroku logs的日志输出:

    2020-05-20T16:58:44.000000+00:00 app[api]: Build succeeded
    2020-05-20T16:58:46.235387+00:00 heroku[web.1]: Stopping all processes with SIGTERM
    2020-05-20T16:58:46.360055+00:00 heroku[web.1]: Process exited with status 143
    2020-05-20T16:58:47.111612+00:00 heroku[web.1]: Starting process with command `node --optimize_for_size --max_old_space_size=460 --gc_interval=100 server.js`
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-13
      • 2019-12-26
      • 2015-09-08
      • 2021-02-02
      • 1970-01-01
      • 2018-12-28
      • 2012-10-22
      • 1970-01-01
      相关资源
      最近更新 更多