1

I've just implemented modules on GAE and am trying to run a Cron job from a certain module. My app.yaml has following values at the top:

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:

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:
- 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. Why is it not accepting the target parameter?

Harshal Patil
  • 6,659
  • 8
  • 41
  • 57
Vincent
  • 1,137
  • 18
  • 40

2 Answers2

1

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.

Vincent
  • 1,137
  • 18
  • 40
  • Can you tell me how to properly set up the handlers for your cron job? I have a similar problem where I'm trying to load another module that needs more memory... just not sure how to setup the handlers in order to run a *.py script as a cron job. So, for example, I have abc.py that I want to run as a cron job that's part of module.yaml. Thank you in advance – user3058197 Apr 07 '14 at 23:03
  • I don't use the distpatch.yaml, so I guess you don't have to update it. My handler in this case would be first line "- url: /update" and then second line "script: update.app" which would call the app from update.py – Vincent Apr 08 '14 at 12:27
  • Thanks for the response -- could you take a look at [this](http://stackoverflow.com/questions/22924934/cron-yaml-doesnt-route-requests-to-proper-module-on-dev-server) and see if you see something wrong? I feel I'm doing everything correctly, but I'm getting 404 errors when I'm trying to run a cron job.. – user3058197 Apr 08 '14 at 12:41
  • Okay, fixed it -- I needed to specifically update cron.yaml with appcfg.py update_cron – user3058197 Apr 08 '14 at 14:50
  • Great. Let me know if you have any questions. – Vincent Apr 09 '14 at 07:59
0

Please check the below text from GAE document - target element for version not module.

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?

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)
Wonil
  • 6,364
  • 2
  • 37
  • 55