如何自动删除旧的Google

如何自动删除旧的Google

本文介绍了如何自动删除旧的Google App Engine版本实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试验更具成本效益的方式来部署我的Rails应用程序,并通过

然后我对我的应用程序并重新部署:

  code>使用模块以Python编写的模块 API: 

  
#核心逻辑(在cron或其他处理程序中)
for m in modules.get_modules():
dv = modules.get_default_version(m)
for v in modules.get_versions(m):
if v!= dv:modules.stop_version(m,v)

这不会删除非默认版本( modules API目前不支持删除),但确实没有任何实例正在运行(因此不会产生任何费用)。



这个核心逻辑是为了让你把它包装在一个处理程序中,所以你可以根据需要触发它,例如在一个cron作业中,或者在一个常规处理中呃你从外面触发(具有适当的认证),例如通过wget或curl在你的bash脚本中。



我不相信Python的Ruby版本 google.appengine.api.modules.modules ,但是,我可能是错的......我只是找不到一个。但是,一个简单的Python编码模块应该允许您控制以任何其他App Engine语言编码的模块(因为App Engine允许混合和匹配以不同语言编码的模块)。


I'm experimenting with more cost effective ways to deploy my Rails apps, and went through the Ruby Starter Projects to get a feel for Google Cloud Platform.

It's almost perfect, and certainly competitive on price, but I can't figure out how to automatically delete old deployed version instances after redeploying.

ie: let's say I have one version of each instance running:

And then I make a change to my app and redeploy with:

$ gcloud preview app deploy app.yaml worker.yaml --promote

So now I have two versions of each instance deployed (as Google switches between them intelligently, I'd assume):

But now what? Will these instances ever turn off by themselves? The best way I've found of getting rid of them so far is from the tutorial's Deleting the project page:

Is everyone on Google App Engine just manually deleting the old deployments of their apps?

解决方案

To stop all instances of all non-default versions of all modules (independently of what languages those modules are in), you could add a small control module, written in Python, using the modules API:

from google.appengine.api.modules import modules

# core logic (inside a cron or other handler)
for m in modules.get_modules():
    dv = modules.get_default_version(m)
    for v in modules.get_versions(m):
        if v != dv: modules.stop_version(m, v)

This doesn't delete the non-default versions (the modules API does not appear to currently support deletion), but does ensure that none of their instances are running (so no charges would be incurred for them).

This core logic is meant for you to wrap it inside a handler, so you can trigger it as required, for example in a cron job, or in a "regular" handler that you trigger from the outside (with appropriate auth) e.g. via wget or curl within your bash scripts.

I don't believe there's a Ruby version of Python's google.appengine.api.modules.modules , but, I could be wrong... I just couldn't find one. However, a simple Python-coded module should let you control modules coded in whatever other App Engine language (since App Engine lets you mix and match modules coded in different languages).

这篇关于如何自动删除旧的Google App Engine版本实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:51