【问题标题】:How to configure two processes in a heroku dyno to communicate with each other如何在heroku dyno中配置两个进程以相互通信
【发布时间】:2020-11-20 14:16:04
【问题描述】:

我正在尝试在单个 heroku dyno 中运行的 2 个进程之间建立通信,根据本文档,这应该是可能的: https://devcenter.heroku.com/articles/dynos#networking

Individual processes within a dyno can bind to any address or port they want and communicate among them using e.g. standard TCP

我正在尝试使用 http,并且代码在我的开发机器上运行良好。但是当我尝试在heroku上执行同样的事情时,源进程无法连接到目标进程。一个进程使用 nodejs 运行,另一个进程使用 python 运行。

这是 Procfile 的内容:

web: npm run start
worker: python3 -m scripts.app

这是来自原始节点进程的 axios 错误消息的一部分:

020-11-17T18:30:22.385020+00:00 app[web.1]: Inside nltk error block
2020-11-17T18:30:22.387506+00:00 app[web.1]: Error: connect ECONNREFUSED 127.0.0.1:5010
2020-11-17T18:30:22.387507+00:00 app[web.1]: at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16) {
2020-11-17T18:30:22.387508+00:00 app[web.1]: errno: 'ECONNREFUSED',
2020-11-17T18:30:22.387508+00:00 app[web.1]: code: 'ECONNREFUSED',
2020-11-17T18:30:22.387509+00:00 app[web.1]: syscall: 'connect',
2020-11-17T18:30:22.387509+00:00 app[web.1]: address: '127.0.0.1',
2020-11-17T18:30:22.387509+00:00 app[web.1]: port: 5010,

【问题讨论】:

    标签: http heroku networking


    【解决方案1】:

    Procfile 定义了进程类型。它们将在单独的容器中运行

    如果您想在一个测功机中运行多个进程,您的 Procfile 应该只有一个条目,并且一个将为您提供服务的进程是子进程。

    several methods and buildpacks to achieve this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-23
      • 2012-03-08
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      相关资源
      最近更新 更多