简体   繁体   English

通过Appengine的cron.yaml运行django manage.py命令

[英]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.

相关问题 如何获取 google appengine 应用程序的当前 cron.yaml? - How to get current cron.yaml for google appengine application? Appengine cron.yaml定义未显示在开发人员控制台中 - Appengine cron.yaml definitions not showing in developer console Google AppEngine获取403禁止尝试更新cron.yaml - Google AppEngine Getting 403 forbidden trying to update cron.yaml 带有Google App Engine和Vagrant的Django manage.py命令 - Django manage.py commands with Google App Engine and Vagrant 即使未定义cron.yaml文件,Google Appengine也会运行Cron任务 - Google Appengine runs Cron tasks even if they are no cron.yaml file defined Django 1.4的./manage.py测试给出了在Google Appengine中找不到的Thing2Literal导入 - ./manage.py test of Django 1.4 gives a Thing2Literal import not found on google appengine 如何为我的应用引擎源代码管理单独的app.yaml / cron.yaml? - How can I manage separate app.yaml / cron.yaml for my app engine source code? 我可以在Google AppEngine中使用cron.yaml调用外部网址吗,可以在其中包含sleep()吗? - Can I call external urls using cron.yaml in Google AppEngine and Can I include sleep() in it? GAE - django manage.py 问题 - GAE - django manage.py problem Travis CI使用cron.yaml部署到gcp - Travis CI deploy with cron.yaml to gcp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM