1

I made a discord python bot and deploy to google cloud app engine but the problem is it restarts every 10 minutes.

app.yaml

runtime: python310

instance_class: B1

manual_scaling:
  instances: 1

entrypoint: python3 bot.py

Error

Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404.

How to fix the problem?

Karan
  • 65
  • 6
  • You need to make the health check of the App Engine healthy and you need to host an HTTP endpoint, even if the Discord bot does not need it, so it does not restart every 10 minutes or so. Refer to this [Link](https://youtu.be/xGKy9Zo8btQ) for more information. The code snippet is [here](https://gist.github.com/yoyu777/3fce7e75e809089965f184994dab201d) – Hemanth Kumar Dec 12 '22 at 12:49
  • But the `http_server.js` is for the js project how can I use it in my python bot? – Karan Dec 12 '22 at 14:49
  • Check pythons [run environment](https://cloud.google.com/appengine/docs/standard/python3/runtime#the_runtimes_environment) and also increase the instances in [manual scaling](https://cloud.google.com/appengine/docs/standard/reference/app-yaml?tab=python#manual_scaling) and check restart may stops. – Hemanth Kumar Dec 13 '22 at 10:17
  • Done all the tricks still restarting. – Karan Dec 13 '22 at 10:27

1 Answers1

2

As per App Engine officials docs, App engine sends periodic health check requests to confirm that an instance is running, and to check that an instance is fully started and ready to accept incoming requests. By default, these health checks are enabled and are known as split health checks. An instance that receives a health check must answer the health check within a specified time interval.

As the instance goes through these health checks , if the instance is healthy it works fine but if the instance is unhealthy then it restarts.

Official docs says :

Unhealthy. The instance refused the health check requests and failed to respond to a specified number of consecutive health check requests. App Engine continues to send health check requests and restarts the instance if an unhealthy instance continues to fail to respond to a predetermined number of consecutive health checks.

Requesting you to try by setting min and max instances in automatic scaling or else use basic scaling as per this doc.

Hemanth Kumar
  • 2,728
  • 1
  • 4
  • 19
  • for a discord bot how many instances are required? – Karan Dec 13 '22 at 11:29
  • @Karan : it depends on the coustomers handling by the bot. for simple check you try to use 5 instances and have a check. Use this [doc](https://gebes.medium.com/how-to-make-your-discord-bot-scaleable-f7d2088edccc) How to make your Discord bot scaleable. – Hemanth Kumar Dec 13 '22 at 11:46
  • @Karan : for error Process terminated because it failed to respond to the start request with an HTTP status code of 200-299 or 404 Refer to this [SO Link](https://stackoverflow.com/questions/27266399/gae-backend-process-terminated-because-it-failed-to-respond-to-the-start-reques) – Hemanth Kumar Dec 13 '22 at 11:47
  • I am new to google cloud and can't figure out the docs. – Karan Dec 13 '22 at 11:55
  • Following on the shared docs will be resolving the issue. If you get any errors post it here. – Hemanth Kumar Dec 13 '22 at 13:38