How to run GAE cron jobs as specific app version?
Asked Answered
B

2

5

Recently I've started using limited staging on my Google App Engine project. The data is still shared between all versions, but behaviour (especially user facing behaviour) is different.

Naturally when I implement something incredibly new it only runs on the latest version of my code and I don't feel like it should be backported to the older versions.

Some of this new functionality requires cron jobs to be run periodically, but I'm hitting a problem. I have to run a cron job to call the latest code, but this is what Google's documentation has to say about the issue:

Cron requests are always sent to the default version of the application.

The default version is the oldest because the first versions of the client code that went out to users weren't future proof and don't know how to select which API version to call.

So my question is, how can I get around this limitation and make a cron job that will call the latest rather than the default version of the application?

Brooklime answered 6/2, 2011 at 14:32 Comment(0)
M
3

You can't change the cron jobs to run on a different version then the default.

Depending on how much time your cron job takes to run you could change your cron job script to to do a URLFetch to "http://latest.appname.appspot.com/cron_job_endpoint".

If you're cron job takes longer then 10 minutes to run, then I would design it in a way that you can chain the different tasks using task queues.

Merkle answered 6/2, 2011 at 16:9 Comment(1)
Thanks for the idea, I made a simple API that acts as a meta-cron and simply calls the url of the actual cronjob on the appropriate app version.Brooklime
C
12

You can now specify a version using the target tag.

<target>version-2</target>
Calvaria answered 17/6, 2011 at 16:38 Comment(1)
In cron.yaml, you can add the line target: 2Pursuer
M
3

You can't change the cron jobs to run on a different version then the default.

Depending on how much time your cron job takes to run you could change your cron job script to to do a URLFetch to "http://latest.appname.appspot.com/cron_job_endpoint".

If you're cron job takes longer then 10 minutes to run, then I would design it in a way that you can chain the different tasks using task queues.

Merkle answered 6/2, 2011 at 16:9 Comment(1)
Thanks for the idea, I made a simple API that acts as a meta-cron and simply calls the url of the actual cronjob on the appropriate app version.Brooklime

© 2022 - 2024 — McMap. All rights reserved.