【问题标题】:Running my own daemon on Heroku, how can I contact it from the Internet?在 Heroku 上运行我自己的守护进程,我如何从 Internet 联系它?
【发布时间】:2019-12-24 21:50:48
【问题描述】:

我有一个在 Heroku 上运行良好的 Django 应用程序。此时,我想启动第二个进程,该进程实现一个守护进程,该进程与其他设备交换数据并填充 Django 应用程序的数据库。

我将第二个守护进程实现为 Django 应用程序的自定义命令,所以在我的 Procfile 中有

web: gunicorn portal.wsgi --log-file -
listener: python manage.py listen_to_devices

此时我使用heroku ps:scale listener=1 启动守护进程。

设备无法连接。在调试时,我注意到我的应用在 DNS 中有几个条目,我猜是为了负载平衡:

ottavio@debian:~$ nslookup xxx.herokuapp.com
Server:     192.168.69.2
Address:    192.168.69.2#53

Non-authoritative answer:
Name:   xxx.herokuapp.com
Address: 52.51.85.80
Name:   xxx.herokuapp.com
Address: 52.212.106.249
Name:   xxx.herokuapp.com
Address: 54.171.30.127
Name:   xxx.herokuapp.com
Address: 54.171.254.93
Name:   xxx.herokuapp.com
Address: 54.194.235.52
Name:   xxx.herokuapp.com
Address: 99.80.174.196
Name:   xxx.herokuapp.com
Address: 52.18.173.71
Name:   xxx.herokuapp.com
Address: 52.48.204.199

ottavio@debian:~$

所以,我想我做错了什么。每当我尝试远程登录时,端口 8080 似乎都没有打开。

如何让我的设备访问我的守护程序端口?

【问题讨论】:

    标签: django python-3.x heroku


    【解决方案1】:

    如何让我的设备访问我的守护程序端口?

    你不能。

    至少,如果您已经有另一个进程已经在侦听网络流量,则您不能这样做。 Dynos with the web type are the only ones that can receive traffic from the internet 和 Heroku only gives you a single $PORT to bind to

    根据它的作用,您也许可以将您的守护进程作为单独的 Heroku 应用程序运行,但一般来说,应用程序希望看到 HTTP 流量。

    【讨论】:

      猜你喜欢
      • 2011-12-30
      • 2023-03-02
      • 2011-12-24
      • 1970-01-01
      • 1970-01-01
      • 2021-02-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多