我想在 Heroku 上部署我的 plotly 儀表板,但是在運行時我不斷收到埠 [PORT_NUMBER] 已經在使用中的資訊。埠號由 Heroku 本身給出,并且每次我重新啟動應用程式時都會更改。我嘗試設定一個具有固定埠的應用程式,但它只是說給定的埠也“被另一個程式使用”。關于類似的事情有一些問題,但它們都與 node.js 應用程式的部署有關,并且似乎已通過使用特定于 node.js 部署的解決方案得到解決。
由于我試圖定位問題,我將我的主模塊縮減為 app.py 檔案中的最小作業示例:
from dash import Dash, html
app = Dash(__name__)
server = app.server
app.layout = html.Div("TESTING")
app.run_server(debug=False)
Procfile 定義如下:
web: gunicorn app:server
這是我不斷收到的正在運行的服務器的日志:
2022-06-05T15:38:23.696572 00:00 app[web.1]: * Serving Flask app 'app' (lazy loading)
2022-06-05T15:38:23.696693 00:00 app[web.1]: * Environment: production
2022-06-05T15:38:23.696830 00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2022-06-05T15:38:23.696863 00:00 app[web.1]: Use a production WSGI server instead.
2022-06-05T15:38:23.696883 00:00 app[web.1]: * Debug mode: off
2022-06-05T15:38:23.702649 00:00 app[web.1]: Address already in use
2022-06-05T15:38:23.702652 00:00 app[web.1]: Port 45013 is in use by another program. Either identify and stop that program, or start the server with a different port.
2022-06-05T15:38:23.702869 00:00 app[web.1]: [2022-06-05 15:38:23 0000] [489] [INFO] Worker exiting (pid: 489)
2022-06-05T15:38:23.850179 00:00 app[web.1]: [2022-06-05 15:38:23 0000] [491] [INFO] Booting worker with pid: 491
2022-06-05T15:38:24.280232 00:00 app[web.1]: Dash is running on http://127.0.0.1:45013/
2022-06-05T15:38:24.280241 00:00 app[web.1]:
2022-06-05T15:38:24.280618 00:00 app[web.1]: * Serving Flask app 'app' (lazy loading)
2022-06-05T15:38:24.284103 00:00 app[web.1]: * Environment: production
2022-06-05T15:38:24.284156 00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2022-06-05T15:38:24.284186 00:00 app[web.1]: Use a production WSGI server instead.
2022-06-05T15:38:24.284209 00:00 app[web.1]: * Debug mode: off
2022-06-05T15:38:24.295838 00:00 app[web.1]: Address already in use
2022-06-05T15:38:24.295891 00:00 app[web.1]: Port 45013 is in use by another program. Either identify and stop that program, or start the server with a different port.
2022-06-05T15:38:24.296221 00:00 app[web.1]: [2022-06-05 15:38:24 0000] [490] [INFO] Worker exiting (pid: 490)
2022-06-05T15:38:24.702612 00:00 app[web.1]: [2022-06-05 15:38:24 0000] [492] [INFO] Booting worker with pid: 492
2022-06-05T15:38:24.826989 00:00 app[web.1]: Dash is running on http://127.0.0.1:45013/
2022-06-05T15:38:24.826991 00:00 app[web.1]:
2022-06-05T15:38:24.827286 00:00 app[web.1]: * Serving Flask app 'app' (lazy loading)
2022-06-05T15:38:24.832077 00:00 app[web.1]: * Environment: production
2022-06-05T15:38:24.832127 00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2022-06-05T15:38:24.832158 00:00 app[web.1]: Use a production WSGI server instead.
2022-06-05T15:38:24.832182 00:00 app[web.1]: * Debug mode: off
2022-06-05T15:38:24.834227 00:00 app[web.1]: Address already in use
2022-06-05T15:38:24.834256 00:00 app[web.1]: Port 45013 is in use by another program. Either identify and stop that program, or start the server with a different port.
2022-06-05T15:38:24.834479 00:00 app[web.1]: [2022-06-05 15:38:24 0000] [491] [INFO] Worker exiting (pid: 491)
2022-06-05T15:38:25.150842 00:00 app[web.1]: [2022-06-05 15:38:25 0000] [493] [INFO] Booting worker with pid: 493
由于埠繁忙,它只是不斷啟動和失敗。
我究竟做錯了什么?
編輯
從頭開始重新部署應用程式解決了這個問題。
uj5u.com熱心網友回復:
如果埠正在更改并且結果保持不變。有以下方法可以嘗試:
- 確認您沒有在一個埠上運行多個服務器。例如,在您的運行配置中,您直接啟動服務器并同時使用
gunicorn。 - 嘗試從頭開始重新部署應用程式。(也許這是在這個特定部署中觸發的一些奇怪的 Heroku 錯誤。)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/486268.html
標籤:python-3.x 烧瓶 heroku 情节地 破折号
下一篇:Heroku無法識別用戶
