錯誤 R10(啟動超時)-> Web 進程無法在啟動後 60 秒內綁定到 $PORT:Rasa 聊天機器人 Heroku

錯誤 R10(啟動超時)-> Web 進程無法在啟動後 60 秒內綁定到 $PORT:Rasa 聊天機器人 Heroku

幾天來我一直在嘗試在 Heroku 上部署機器人,但沒有成功。我的機器人有一個託管在另一個應用程式上的操作伺服器。主機器人包含一個 Dockerfile,其內容如下:

# from rasa base image
FROM rasa/rasa:2.8.2-full
# copy all source and the Rasa generated model
COPY . /app

# inform which port will run on
EXPOSE 5005

# script to run rasa core
COPY startup.sh /app/scripts/startup.sh
# script to run rasa shell
COPY shell.sh /app/scripts/shell.sh

USER root
RUN chmod a+x /app/scripts/startup.sh
RUN chmod a+x /app/scripts/shell.sh

WORKDIR /app

ENTRYPOINT []
ENV shell_mode false

# launch script (rasa shell or rasa run)
CMD sh -c 'if [ "$shell_mode" = false ]; then /app/scripts/startup.sh; else  /app/scripts/shell.sh; fi'

在heroku上推送這個容器後,我不斷收到以下日誌:

2021-08-08T05:05:19.003044+00:00 heroku[web.1]: Starting process with command `/bin/bash -o pipefail -c sh\ -c\ \'if\ \[\ \"\false\"\ \=\ false\ \]\;\ then\ /app/scripts/startup.sh\;\ else\ \ /app/scripts/shell.sh\;\ fi\'`
2021-08-08T05:05:22.624829+00:00 app[web.1]: PORT 56161
2021-08-08T05:05:28.172219+00:00 app[web.1]: 2021-08-08 05:05:28 INFO     root  - Starting Rasa server on http://localhost:56161
2021-08-08T05:05:28.198725+00:00 app[web.1]: 2021-08-08 05:05:28 INFO     rasa.model  - Loading model models/20210807-142446.tar.gz...
2021-08-08T05:06:19.182952+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2021-08-08T05:06:19.237369+00:00 heroku[web.1]: Stopping process with SIGKILL
2021-08-08T05:06:19.401953+00:00 heroku[web.1]: Process exited with status 137
2021-08-08T05:06:19.707060+00:00 heroku[web.1]: State changed from starting to crashed

我的startup.sh包含:

echo PORT $PORT
rasa run -m models --endpoints heroku-endpoints.yml --cors "*" --enable-api -p $PORT

我究竟做錯了什麼?請幫忙。

答案1

我遇到了同樣的問題,但是在部署 python slackbot 時。我正在使用gunicorn,問題似乎是gunicorn沒有及時將自己綁定到heroku提供的連接埠。--bind :$PORT如前所述,透過向 Procfile新增選項解決了這個問題這裡

確保gunicorn的bind已經成功的日誌是這樣的

2021-09-06T17:43:34.126351+00:00 app[web.1]: [2021-09-06 17:43:34 +0000] [4] [INFO] Starting gunicorn 20.1.0
2021-09-06T17:43:34.127129+00:00 app[web.1]: [2021-09-06 17:43:34 +0000] [4] [INFO] Listening at: http://0.0.0.0:47022 (4)

我知道這沒有直接關係,但希望對你有幫助!

您可以嘗試的另一件事是從腳本發出傳出請求,這暫時解決了我的問題,並強制應用程式使用連接埠發送一些出站流量。您可能會發現應用程式的啟動時間可能太長,無法及時將自身綁定到端口

相關內容