0

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!

Lucas Ou-Yang
  • 5,505
  • 13
  • 43
  • 62

1 Answers1

1

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
dragonx
  • 14,963
  • 27
  • 44
  • 1
    With the current setup I have above, i'm getting 500 errors from performing test runs on localhost:8000/cron. What do you mean they don't run on production servers? They definitely can be run on cron though, and that is what I need. Do you by any chance know what the setup looks like? – Lucas Ou-Yang Sep 07 '13 at 16:05
  • Are you talking about django management commands? ie (python manage.py runserver)? Because those don't run on production. It looks like you simply have a cron handler. You can simply try accessing the /my_model/management/commands url and debug what's going on in your operate.py script. – dragonx Sep 07 '13 at 16:33
  • No I meant that I'm not sure on how to call a python script properly after hitting a url. For example in urls.py would it be url('^/my_model/management/commands/$', 'Path.to.script.method?') Instead of 500 errors im not getting repeated 404s – Lucas Ou-Yang Sep 07 '13 at 16:36