在google app引擎上在登台环境中处理cron作业 [英] Handling cron jobs on staging environment on google app engine

查看:230
本文介绍了在google app引擎上在登台环境中处理cron作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Google App Engine上设置暂存环境,并在以下问题中找到了良好的指导:如何在Google App Engine上设置暂存环境



问题我是在这种情况下如何处理Cron作业。理想情况下,我只需要更改版本以部署到生产,但是我担心这将意味着所有的cron作业也运行在临时版本上,或者不是这样?

解决方案

如果您使用的是不同版本的方法,您需要注意


如果目标参数已经为作业设置,请求是
发送到指定的版本。否则Cron请求会发送到应用程序的
默认版本。


我一直在使用 target 参数将cron作业定向到不同的模块,基于上面的引用我可以使用将作业指向不同的版本=https://cloud.google.com/appengine/docs/python/modules/routing#routing_via_url =nofollow>通过网址的模块路由,可能类似如下:

  target:version 

  target:version-dot-module 

个人而言,我喜欢不同的应用程序方法,以确保暂存和生产环境之间没有干扰,即使执行大规模重新工作破坏向后兼容性)。



对于方法,我使用来自两个不同分支的两个不同的工作区,它们之间有最小的差异(应用程序 .yaml 文件和其他与分期相关的增量):




  • a staging 工作区&分支

  • a 生产工作区&分支



每当我对 staging 分支中的代码感到满意:生产 / code> one c 更新生产工作区并从中部署 - >更新 工作区( c> staging 工作区 - >更新 c> staging app


这个方法可能会在不同版本的方法中使用好的, .yaml 文件中的版本字段在2个分支中是不同的。


I want to set up a staging environment on Google App Engine and have found good guidance for this in the following question: How to set up a staging environment on Google App Engine

The only unanswered question I have is how to handle Cron jobs in this case. Ideally I'll just have to change the version to deploy to production, however I fear that that would mean that all cron jobs also run on the staging version, or is this not the case?

解决方案

If you're using a different version approach you need to pay attention to this:

If the target parameter has been set for a job, the request is sent to the specified version. Otherwise Cron requests are sent to the default version of the application.

I've been using the target parameter to direct cron jobs to different modules, based on the quote above I guess it could be used to direct jobs to different versions as well, using module routing via URL, probably something like this:

  target: version

or

  target: version-dot-module

Personally I prefer a different application approach to ensure no interference between the staging and the production environments, even when performing massive re-works breaking backwards compatibility :)

As for the method, I use 2 different workspaces from 2 different branches of the code, which have minimal differences between them (the application fields in the .yaml files and maybe other staging-related deltas):

  • a staging workspace & branch
  • a production workspace & branch

Whenever I'm happy with the code in the staging branch I:

  • merge the staging branch in the production one
  • update the production workspace and deploy from it -> updating the production app
  • disable whatever I need in the staging workspace (committing the changes to the staging branch as well if so desired)
  • deploy from the staging workspace -> updating the staging app

Probably the method would be usable in a different version approach as well, the version fields in the .yaml files being different in the 2 branches.

这篇关于在google app引擎上在登台环境中处理cron作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆