简体   繁体   English

GAE Python-Cron作业未在目标模块上执行

[英]GAE Python - Cron job doesn't execute on the target module

I've just implemented modules on GAE and am trying to run a Cron job from a certain module. 我刚刚在GAE上实现了模块,并试图从某个模块运行Cron作业。 My app.yaml has following values at the top: 我的app.yaml在顶部具有以下值:

application: myapp
module: default
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
#all handlers

The reporting.yaml for the module I am trying to activate has the following settings: 我尝试激活的模块的report.yaml具有以下设置:

application: myapp
module: reporting
version: 1
instance_class: B4
runtime: python27
api_version: 1
threadsafe: true

handlers:
#same handlers as app.yaml

Finally my cron.yaml looks as following: 最后,我的cron.yaml如下所示:

cron:
- description: update reports
  url: /update
  schedule: every day 12:00
  target: reporting

I need the module because the job requires more memory then the normal instance offers. 我需要模块,因为工作需要比普通实例更多的内存。 For some reason however, when I look in the Logs of my app, it keeps executing the cron job on the default module. 但是由于某种原因,当我查看应用程序的日志时,它将继续在默认模块上执行cron作业。 Why is it not accepting the target parameter? 为什么不接受目标参数?

Turns out I missed to upload the module itself with following command: 原来我错过了使用以下命令上传模块本身:

appcfg update app.yaml reporting.yaml

After doing this, the target parameter worked. 完成此操作后,目标参数起作用。

Please check the below text from GAE document - target element for version not module. 请检查GAE文档中的以下文本-版本而非模块的目标元素。

If the target parameter has been set for a job, the request is sent to the specified version . 如果已经为作业设置了目标参数,则将请求发送到指定的版本

How about forward cron job to your target module as like the below example code in GAE document ? 像下面GAE文档中的示例代码一样,如何将cron作业转发到目标模块?

import urllib2
from google.appengine.api import modules

url = "http://%s/" % modules.get_hostname(module="reporting")
try:
  result = urllib2.urlopen(url)
  doSomethingWithResult(result)
except urllib2.URLError, e:
  handleError(e)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM