1

I have been trying to deploy a bot on heroku for days now without success. My bot has an action server hosted on another app. The main bot contains a Dockerfile with the content below:

# 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'

After pushing this container on heroku, I keep getting the following log:

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

My startup.sh contains:

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

What am I doing wrong? Kindly help.

Sirjon
  • 11
  • 1
  • 3

1 Answers1

1

I encountered the same issue, but when deploying a python slackbot. I was using gunicorn, and the issue seems to be that gunicorn did not bind itself to the port provided by heroku in time. This was resolved by adding --bind :$PORT option to the Procfile as mentioned here

The log that ensures that gunicorn's bind has been successful is this

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)

I know it is not directly related, but hope that helps you!

Another thing you can try is to make an outgoing request from your script, that solved my issue temporarily as well as it forces the application to use a port to send some outbound traffic. You may find that maybe the startup of the application is taking too long and it is not able to bind itself to the port in time

akshatd
  • 11
  • 2