Warmup requests for PHP 7.2? - google-app-engine

The current documentation of AppEngine for PHP 7.2 does not mention warmup requests. While I can configure some warmup settings, I cannot specify a specific handler.
app.yaml excerpt:
# url handlers
handlers:
- url: /_ah/warmup
script: warmup.php
login: admin
- url: /.*
script: auto
# run url request on startup
inbound_services:
- warmup
Error:
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: script field for handler '/_ah/warmup' must be set to 'auto' for runtime php72.
How can I securely receive warmup requests now?

Related

How to stop warmup requests in Google App Engine?

I'm getting warmup request every second in my GAE Python app, it results in 404, my app.yaml is below:
runtime: python37
entrypoint: gunicorn -w 4 -k uvicorn.workers.UvicornWorker api:app
instance_class: F4
inbound_services:
- warmup
handlers:
- url: /_ah/warmup
script: auto
- url: /.*
static_dir: /.*
http_headers:
Access-Control-Allow-Origin: "*"
# ...
I've tried removing the inbound_services: - warmup, but the requests didn't stop, they also appear to be originated from an earlier version, any idea on how can I stop them?
similar issue: Too many /_ah/warmup/ queries on Google App Engine
I'm not sure about stopping them, I would think that removing inbound_services: - warmup would stop it.
As for your original issue of the 404s though, you need to setup a handler in your python code for the url /_ah/warmup, since you specified script: auto

App Engine Task Queue Handler throws 302 Error

I have an App Engine Python Application which has an endpoint that puts a task in the Task Queue. - This is working fine.
I have a Task Handler Python Application which will be execute the task in the queue.
When the task handler is invoked, the below error accurs
Request failed because URL requires user login. For requests invoked within App Engine (offline requests like Task Queue, or webhooks like XMPP and Incoming Mail), the URL must require admin login (or no login).
My App Engine Python Application app.yml is below
service: dataload-test
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
- url: /_ah/queue/deferred
script: google.appengine.ext.deferred.deferred.application
login: admin
libraries:
- name: ssl
version: latest
builtins:
- deferred: on
- appstats: on
env_variables:
GAE_USE_SOCKETS_HTTPLIB : 'true'
My Task Handler Application app.yml is below
service: adobe-dataload-worker
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: load_data_worker.app
login: admin
Any help would be appreciated
Your wildcard - url: /.* handler is handling EVERY URL.
Put that last, or else the deferred handler will never be seen:
handlers:
- url: /_ah/queue/deferred
script: google.appengine.ext.deferred.deferred.application
login: admin
- url: /.*
script: main.app

Google App Engine + Cloud Endpoints + Google Translate API = 502 Bad Gateway

I have created a simple API using Cloud Endpoints, which makes some translations using Google Translate API, caches them in Datastore and returns the list of results to Client.
The problem is that each time I make a call, which uses Google Translate API I receive 502 Bad Gateway error.
I've been debugging my endpoint from cloud console and the response is created successfully, so the 502 must be thrown when sending the result back to client. Another strange thing here is that I don't see 502 on any logging tool in Cloud Console.
I was trying to change region from europe-west to us-central, but no luck so far.
Does anyone have any ideas, what may be wrong here?
My cofnig of GAE:
runtime: java7
env: standard
threadsafe: true
instance_class: B2
inbound_services:
- warmup
handlers:
- url: '(/.*/)'
application_readable: false
static_files: "__static__\\1index.html"
require_matching_file: true
upload: __NOT_USED__
- url: (/)
application_readable: false
static_files: "__static__\\1index.html"
require_matching_file: true
upload: __NOT_USED__
- url: '(/.*)'
application_readable: false
static_files: "__static__\\1"
require_matching_file: true
upload: __NOT_USED__
- url: /
script: unused
- url: '/.*/'
script: unused
- url: '/_ah/.*'
script: unused
basic_scaling:
idle_timeout: 900s
max_instances: 2
When changing configuration of GAE and removing basic-scaling I get from Google translate following error:
com.google.cloud.translate.TranslateException: com.google.apphosting.api.ApiProxy$CancelledException: The API call urlfetch.Fetch() was cancelled because the overall HTTP request deadline was reached.
at io.stringx.repository.DatastoreTranslationRepository.translate (DatastoreTranslationRepository.java:53)
It turned out that Google Cloud Endpoints have 60s deadline limit, so I had to make my requests in chunks:
https://cloud.google.com/appengine/articles/deadlineexceedederrors#UrlFetch_Delays

Protecting cron scheduling endpoint on AppEngine (Flexible Environment)

I am trying to get my dataflow job scheduled via cron.yaml in an AppEngine flexible environment. This works flawlessly when I leave my endpoint unprotected. However, when trying to secure the endpoint, I see 403 status responses, even when triggering it from within the TaskQueues interface.
My app.yaml looks like this:
runtime: java
env: flex
handlers:
- url: /.*
script: this field is required, but ignored
- url: /dataflow/schedule
script: this field is required, but ignored
login: admin
runtime_config:
jdk: openjdk8
resources:
cpu: .5
memory_gb: 1.3
disk_size_gb: 10
manual_scaling:
instances: 1
Secure handlers (like login: admin) do not work on App Engine Flexible, that is why the 403.
For securing that handler, you can check the request header "X-AppEngine-Cron" in your app, which is a trusted header only set by traffic coming from App Engine.

App Engine Python Modules and inbound mail service

I am using App Engine Modules in my python project. (https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads)
I am also receiving email in m project:
https://developers.google.com/appengine/docs/python/mail/receivingmail
I want to direct the emails to my worker module and not the default module. To that end my worker.yaml has the following settings
worker.yaml
api_version: 1
application: integrate
module: worker
version: 1-0-0
runtime: python27
threadsafe: true
inbound_services:
- mail
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.worker.main.app
login: admin
- url: /_ah/mail/.+
script: src.worker.main.app
login: admin
- url: /.*
script: src.worker.main.app
app.yaml
api_version: 1
application: integrate
version: 1-0-0
runtime: python27
threadsafe: true
builtins:
- deferred: on
handlers:
- url: /admin/.+
script: src.default.main.app
login: admin
- url: /.*
script: src.default.main.app
I even tried adding a dispatch.yaml
application: integrate
dispatch:
- url: "*/_ah/mail/.+"
module: worker
But no matter what I do the emails which reach my app are handled by the default module. Any idea what I am missing here? I see the emails coming in but no matter what I do they only go to the default module.
Inbound services could be used only within default module and that is expected behavior. The fact that it works for you locally in devserver is a bug, actually.
Just some additional info for the answer which may help folks in a similar situation.
I noticed in the DevServer log:
"Skipping dispatch.yaml rules because /_ah/mail/[EMAIL_ADDRESS_FOR_APP] is not a dispatchable path."
This is no doubt due to local config, however.
Regardless, the workaround I have now using Tasks is:
Dispatch or directly handle Inbound Mail in the default module
Provide a script handler that creates a Task, taking the relevant MailMessage data as the payload
Set the TaskQueue in queue.yaml to target the module you wish to process the payload data, e.g. a 'worker' module

Resources