node.js - Heroku - “没有网络进程正在运行”消息,但服务器已经启动
问题描述
Heroku 和我的 Node / Express / MongoDB 应用程序面临以下问题:
XXXX-05-10T22:56:41.782988+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=fast-depths-03410.herokuapp.com request_id=d42d214e-051d-4ba9-842f-ad98cedaf4ab fwd="xxx.xxx.xxx.xxx" dyno= connect= service= status=503 bytes= protocol=https
我在很多帖子中看到这个错误与测功机规模有关,但我认为情况并非如此。
正如您在以下日志中看到的,该应用程序正在运行:
XXXX-05-10T22:41:56.098412+00:00 app[api.1]: yarn run v1.22.5
XXXX-05-10T22:41:56.253837+00:00 app[api.1]: $ node index.js
XXXX-05-10T22:41:57.849610+00:00 app[api.1]: server started on port 23804 (development)
但是当我尝试访问我的 Heroku 应用程序时:https ://fast-depths-03410.herokuapp.com/我唯一能看到的是消息
应用程序错误检查日志..."
关于我的应用程序,我尝试了以下操作:
- 我已经用
heroku ps:scale {myapp-name}=1
- 我已更改要使用的侦听端口
process.env.PORT
- 我已经
EXPOSE $PORT
在我的Dockerfile
有什么问题,我该如何解决?
解决方案
你有一些东西在运行,但它不是一个web
过程。您的日志显示了一个api
过程:
XXXX-05-10T22:41:57.849610+00:00 app[api.1]: server started on port 23804 (development)
^^^
对于非 Docker 部署,进程类型由您定义Procfile
,并且只有web
进程可以接收来自互联网的流量。在这种情况下,改变你Procfile
的
api: some command
至
web: some command
并重新部署。
如果您使用web
process-type
的是 Docker,请确保在构建和推送映像时以及稍后发布时使用,例如:
heroku container:push web
heroku container:release web
推荐阅读
- sql-server - 无法加载文件或程序集 Crystaldecisions.shared 或其依赖项之一
- puppeteer - 仅针对最新浏览器版本进行 E2E 测试有什么好处
- python - 熊猫:如何将值相加,仅当它们具有相同的数字时
- php - 如何在表单提交后显示的页面顶部添加“已发送消息”消息(现在不显示)?
- c - 如何使用 C 正则表达式提取子匹配
- hadoop - Hive 表中的分区和集群方式如何工作?
- javascript - 如何从输入字段中获取数据到我的 ajax 请求中?
- php - 在目录中安装文件的 PHP 脚本
- python - 在windows中使用pycharm中创建的virtualenv在linux中使用
- android - 仅针对浏览器查看器显示横幅,在 android 应用程序用户 (webview) 上不可见