要让Google App Engine应用程序停止自身,您可以采取以下几种方法:
from flask import Flask, request
app = Flask(__name__)
@app.route('/shutdown', methods=['POST'])
def shutdown():
func = request.environ.get('werkzeug.server.shutdown')
if func is None:
raise RuntimeError('Not running with the Werkzeug Server')
func()
return 'Server shutting down...'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080)
gcloud auth login
登录,并通过gcloud config set project [YOUR_PROJECT_ID]
设置项目。gcloud app versions stop [VERSION_ID]
或者停止整个服务:
gcloud app services disable [SERVICE_NAME]
领取专属 10元无门槛券
手把手带您无忧上云