GAE shutdown or restart all the active instances of a service/app

后端 未结 2 451
Happy的楠姐
Happy的楠姐 2020-12-11 22:16

In my app (Google App Engine Standard Python 2.7) I have some flags in global variables that are initialized (read values from memcache/Datastore) when the instance start (a

2条回答
  •  被撕碎了的回忆
    2020-12-11 23:01

    It's possible to use the Google Cloud API to stop all the instances. They would then be automatically scaled back up to the required level. My first attempt at this would be a process where:

    1. The config item was changed
    2. The current list of instances was enumerated from the API
    3. The instances were shutdown over a time period that allows new instances to be spun up and replace them, and how time sensitive the config change is. Perhaps close on instance per 60s.

    In terms of using the API you can use the gcloud tool (https://cloud.google.com/sdk/gcloud/reference/app/instances/):

    gcloud app instances list
    

    Then delete the instances with: gcloud app instances delete instanceid --service=s1 --version=v1

    There is also a REST API (https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions.instances/list):

    GET https://appengine.googleapis.com/v1/{parent=apps/*/services/*/versions/*}/instances
    DELETE https://appengine.googleapis.com/v1/{name=apps/*/services/*/versions/*/instances/*}
    

提交回复
热议问题