나는 며칠 동안 성공하지 못한 채 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의 바인딩이 성공했음을 확인하는 로그는 다음과 같습니다.
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)
직접적인 관련은 없지만 도움이 되셨으면 좋겠습니다!
시도할 수 있는 또 다른 방법은 스크립트에서 나가는 요청을 만드는 것입니다. 그러면 내 문제가 일시적으로 해결될 뿐만 아니라 애플리케이션이 일부 아웃바운드 트래픽을 보내기 위해 포트를 사용하도록 강제합니다. 아마도 애플리케이션 시작에 너무 오랜 시간이 걸리고 제때에 포트에 바인딩할 수 없는 경우가 있을 수 있습니다.