[英]Running django manage.py commands via appengine's cron.yaml
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. 我知道对于cron任务,需要三个处理程序。 One in the cron.yaml, the app.yaml, and the script itself.
在cron.yaml,app.yaml和脚本本身中包含一个。
But what about management commands, which themselves already have a unique structuring. 但是管理命令呢?它们本身已经具有独特的结构。
Here is my cron.yaml 这是我的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 这是我的app.yaml
handlers:
- url: /my_model/management/commands
script: operate.py
Examples would help a lot, thanks! 例子会很有帮助,谢谢!
Management commands are the same as django management commands. 管理命令与django管理命令相同。 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. 不需要管理命令的任何处理程序,它们无需在生产服务器上运行,也不需要响应HTTP请求而运行。
EDIT: 编辑:
cron.yaml simply specifies a url to call on a scheduled basis. cron.yaml只是指定一个要定期调用的URL。 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.
这是一个示例,其中cron调用与其他调用一样,但是利用App Engine的身份验证来确保随机的人不会访问它。 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:
在这种情况下,该请求仍将通过Django的请求处理进行路由,并且您必须将适当的处理程序添加到urls.py中:
- url: /cron
script: djangoappengine.main.application
login: admin
- url: /.*
script: djangoappengine.main.application
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.