I am using Taipy and I need to deploy my app on Heroku. I keep getting error "Web process failed to bind to $PORT within 60 seconds of launch". Here is an image of the log file below.
my Procfile
web: python main.py --host=0.0.0.0
echo ${GOOGLE_CREDENTIALS} > /app/google-credentials.json
I have included the main.py script. The last line of the script contains the rn function which is used to run the taipy
server on default port 5000
. I don't know how to adjust the run()
function to accept heroku default port.
**Edit: main.py **
. . .
if __name__ == "__main__":
Core().run()
scenario = tp.create_scenario(scenario_cfg)
scenario_search = tp.create_scenario(text_search_scenario_cfg)
scenario_search_image = tp.create_scenario(image_search_scenario_cfg)
Gui(pages = pages).run()
If you want to handle web requests on Heroku, your service needs to listen on the right port. This is provided at runtime via the PORT
environment variable:
On Heroku, apps are completely self-contained and do not rely on runtime injection of a webserver into the execution environment to create a web-facing service. Each web process simply binds to a port, and listens for requests coming in on that port. The port to bind to is assigned by Heroku as the
PORT
environment variable.
This can be done in main.py
, but the easiest solution is probably to add the --port
option to the web
process in your Procfile
:
web: python main.py --host=0.0.0.0 --port=$PORT
Note that the second line in your Procfile
won't do anything. Procfile
s aren't scripts, so you can't run arbitrary commands like that. They define process types.
If you can set your credentials some other way (e.g. read them directly from the environment variable instead of dumping that variable to a file and reading the file), I suggest you do that. If you really need that file to exist, you may want to consider writing a wrapper shell script to create the file and start your application.