cron job in google app engine not working -


i have taken basic python 3 tutorial website on flask google cloud tutorial , able set , website works fine.

in addition , wanted run python script runs everyday collect data, cron job doesn't work. added login: admin restrict directly use url

cron.yaml

cron: - description: test dispatch vs target   url: /cronapp   schedule: every 5 hours 

app.yaml

runtime: python env: flex entrypoint: gunicorn -b :$port main:app  runtime_config:   python_version: 3  handlers: - url: /cronapp   script: cronapp.py   login: admin 

i calling http://myproject.appspot.com/cronapp doesn't work , returns 404. doing wrong ? appreciated

your app.yaml file mixing standard environment handlers element flexible environment configuration, ignored. can see cron requests in app's logs in developer console (likely errors, though).

you need add handler /cronapp inside app code, not in app.yaml. not entirely sure how (i'm still using standard environment), depends on app and/or framework. take @ hello world code review flask example.

update:

i may not entirely correct, based answer on documentation noticed inconsistencies (i sent documentation feedback google it).

the flexible environment securing urls cron (which appears copied the standard environment equivalent) mentions couple of solutions:

  • one indeed based on login: admin option handler:

you can restrict url adding login: admin handler configuration section in app.yaml. more information see securing urls

but handler not mentioned in configuring app app.yaml , securing urls pointing inexistent tag. i'm not sure if indeed working or not.

  • the second 1 based on x-appengine-cron header (same in standard environment):

requests cron service contain http header:

x-appengine-cron: true 

the x-appengine-cron header set internally google app engine. if request handler finds header can trust request cron request. if header present in external user request app, stripped, except requests logged in administrators of application, allowed set header testing purposes.

but in removed headers mentioned that:

in addition, selected headers match following pattern removed request:

  • x-appengine-*

it's unclear if extends x-appengine-cron or not. it's worth try. check in (standard env, webapp2-based) cron handler code:

    if self.request.headers.get('x-appengine-cron') none:         self.abort(403)  # httpforbidden 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -