How to explicitly stop the dynamic backend of the Google App Engine when the start handler terminates?

I have a backend that consumes a queue in its starting handler. When the queue is exhausted, the start handler will stop. I want the backend to stop when the start handler ends. I have another code that will send a request to the backend if it adds an item to this queue. These requests simply serve to cause GAE to launch the backend so that it can start consuming the queue.

I do not want the backend to ever be in a state where the start handler has completed, but the backend remains inactive. I want it to stop, so the next server request will cause GAE to start the backend again, run the start handler again and start consuming the queue.

How to achieve this goal?

+4
source share
2 answers

The backend cannot (currently) start and stop programmatically. This is similar to what you want, however, is a common task queue task that behaves exactly as described.

+1
source

If you configure your server as a dynamic backend, the backend will automatically stop 15 minutes after processing the trigger request. If you do not send this start-up request again within the next 15 minutes, the backend will automatically shut down. Unfortunately, you still have to pay a minimum of 15 minutes for uptime, even if the backend does not work during these 15 minutes. I do exactly what you do in my application - the backend starts, starts the leasing task from the pull queue and is idle when the empty queue is empty. I do this once an hour, so I end up paying 24/3 = 8 hours of uptime every day. Since this is below the 9-hour quota, I'm happy (for now).

0
source

All Articles