Question

I don't believe that this question has actually been asked online before.

I'm aware that for cron'd tasks, there needs to be three handlers. One in the cron.yaml, the app.yaml, and the script itself.

But what about management commands, which themselves already have a unique structuring.

Here is my cron.yaml

cron:
- description: operate on new models every 10 minutes
url: /my_model/management/commands
schedule: every 10 minutes

Here is my app.yaml

handlers:
- url: /my_model/management/commands
script: operate.py

Examples would help a lot, thanks!

Was it helpful?

Solution

Management commands are the same as django management commands. They only run locally from the command prompt.

There's no need for any handlers for management commands, they don't run on production servers, and they don't run in response to HTTP requests.

EDIT:

cron.yaml simply specifies a url to call on a scheduled basis. You can treat that url like other urls. Here's an example where the cron calls are treated like other calls, but take advantage of App Engine's authentication to make sure random people are not accessing it. In this case, the request will still get routed through django's request handling, and you'll have to add the appropriate handler to urls.py:

- url: /cron
  script: djangoappengine.main.application
  login: admin

- url: /.*
  script: djangoappengine.main.application
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top