I have telegram bot code which written in python. before digital ocean I use Heroku free version and my bot working fine but when I try to deploy same bot on digital ocean its showing Deploy Error: Health Checks

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

👋 @dropguruji

Great question, I also run a Telegram bot on App Platform (though mine is written in Go) and ran into this same issue.

App Platform expects some sort of service to exist which can be tested against using HTTP or TCP. Though Telegram bots are usually listeners so this healthcheck fails.

My solution was to start a small http server running on port 8080 that returns healthy and some recent stats for my bot. It serves as a healthcheck for App Platform to know my app is still running, and as a way for me to see some information about my bot while running.

Setting up a simple python http/tcp response should resolve this issue.

Hope that helps!

  • I was mulling over a solution that didn’t require code changes, my colleague recommended adding a simple server to handle the TCP response, for you could prefix your service Run command with something like:

    headers=$(echo -ne "HTTP/1.0 200 OK\nContent-Type: text/plain\nContent-Length: 45")
    { while true; do echo -e "$headers\n\nHello from bash\n$(date)" | nc -l $PORT; done; } & python <your_startup_script>
    

    Note the last part after the & is what starts your service. This will cause netcat (nc) to listen on the expected port and respond to the healthchecks.

    The downside to this method is if your app stops running, it will still appear healthy to App Platform.