Monkey Raptor

Thursday, December 28, 2017

Google App Engine: Avoiding "Failed" for Cron Job Test or Actual Schedule

Cron job in computing means scheduled task (job). Cron is derived from Chronus or Khronos, Χρόνος, time.

For your information, I use Python environment.

We can make automated scheduled tasks for our application, here's how.

Now, this isn't included in documentation, or I didn't read that, or it is implicit, uh, hm, anyawyawawa, that is, if we provide HTTP headers or response headers (content-type, content-encoding, pragma, etc) for the URL being used for the automated job, on the App Engine dashboard, when we test (manually run) the task in production (or observing the periodical running task), the status will be failed. But the process itself is actually successfully done, no error, no whatsowhatso. We've got a "wrong status".

What we need to do to avoid that (wrong status) is to eliminate the HTTP headers for the URL used for the cron job. Use a filter, like if filter in the (for instance in Python: your_own_cron_task.py) URL handler.

If the the task trigger is manual, e.g. we trigger that ourselves (not originating from Google App Engine, this is the reference, scroll down to "Cron requests" section), and we need a response for the task being done, use the HTTP headers, since we need to see the actual response status and such via HTTP. But when it is an automated task (the request originates from Google App Engine), we do not include HTTP headers for that URL.

That was from trial and error from my own application. So, I hope it works for you too.

The tip above is applicable only if your cron job(s) is(are) properly written (no error), included in cron.yaml (for Python environment) with correct scheduling syntax, and working (successfully tested) in local development server. I sometimes forget about the HTTP headers, thus, this tip.

Alrighty, that is all.

Google App Engine: Avoiding "Failed" for Cron Job Test or Actual Schedule
https://monkeyraptor.johanpaul.net/2017/12/google-app-engine-avoiding-failed-for.html

No comments

Post a Comment

Tell me what you think...