How to run GAE cron jobs as specific app version?

2k views Asked by At

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?

2

There are 2 answers

1
dplouffe On BEST ANSWER

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.

1
Andrew Uricchio On

You can now specify a version using the target tag.

<target>version-2</target>