Endpoints: /_ah/api/ returns 404 after update - google-app-engine

Problem fixed via Google Cloud support:
I removed the /_ah/spi/* handler from my endpoints yaml file, and the
- url: /.*
script: api.app
did not instantiate the endpoint.
It used to work before since the API was deployed for the previous version, but with the new version, there was nothing explicit to deploy the endopoints. So handlers need to be
handlers:
- url: /_ah/spi/.*
script: api.app
- url: /.*
script: api.app
Keeping the issue below for reference purposes
I've just deployed a new version of my application, and calls to http://app.appspot.com/_ah/api/app/version/method now return a 404. It worked perfectly before the update.
However, there's no trace at all in the logs, and no instance launched when I call/ping those URIs.
While if I call /_ah/whatever/app/version/method, I still have a 404, but it appears in my module logs, and it has the following message
{"state": "APPLICATION_ERROR", "error_message": "Not Found"}
The app is configured using modules, my app.yaml is defined with
application: appname
version: 2015-04-07
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /_ah/spi/.*
script: api.api.app
- url: /.*
script: www.www.app
secure: always
libraries:
- name: pycrypto
version: latest
- name: endpoints
version: 1.0
- name: webapp2
version: latest
- name: jinja2
version: latest
And, in api/api.yaml
application: appname
module: default
version: 2015-04-07
runtime: python27
api_version: 1
threadsafe: true
inbound_services:
- warmup
handlers:
- url: /.*
script: api.app
libraries:
- name: pycrypto
version: latest
- name: endpoints
version: 1.0
- name: ssl
version: latest
I've updated the app to serve this new version in the admin console, and all other modules work perfectly.
Also, I can't see my API in the API explorer, https://appname.appspot.com/_ah/api/explorer returns an empty list (while I see it when running the dev server on localhost).
Update: I've just noticed, looking at #bossylobster reply in GAE cloud endpoints - Api not updating after deploy, that I do not have "Successfully updated API configuration" in my logs after the "Completed update of a new alternate version". However, I have "API deletion serving" at about the time everything started to be 404. Yet, I have no idea why there's this API deletion query in my logs. Any idea of what can be wrong?
That's an app in production and so the mobile version is down at the moment. I'm happy to send the app ID to a devrel in PM if that helps.

Related

Gcloud deploy is not deploying a folder

I am servicing a system.
An old App Engine tool was used to deploy, but it is now obsolete and I need to use the gcloud command line.
However, gcloud is ignoring one system folder and deploying all others.
One big reason this must be happening is because they developed this system based on node_modules and didn't build the code before uploading. In short, I need the node_modules folder for the code to execute.
I already disabled .gcloudignore, but there have been no changes.
Source folder structure:
Folder Structure in App Engine:
I ran the --verbosity = info code on my gcloud deploy and it appeared that they were ignoring it:
My app.yaml:
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: jinja2
version: 2.6
- name: lxml
version: 2.3
- name: pycrypto
version: 2.6
handlers:
- url: /static
static_dir: app/static
secure: always
- url: /.*
script: manage.app
secure: always
builtins:
- remote_api: on
By default, flask use a "templates" folder to contain all your template files(any plain-text file, but usually .html or some kind of template language such as jinja2 ) & a "static" folder to contain all your static files(i.e. .js .css and your images).
So ideally you should not use /static folder
you will need to update app.yaml to include handler static_dir: static
runtime: python27
api_version: 1
threadsafe: true
libraries:
- name: ssl
version: latest
# [START handlers]
handlers:
- url: /static
static_dir: static
- url: /.*
script: main.app
# [END handlers]
The best way to use is
from flask import Flask
app = Flask(__name__, static_folder='static', static_url_path='')

How to properly setup modules for Google App Engine (PHP runtime)

I want to create very standard setup for GAE (php runtime): 2 modules with specific URLs (routings):
module-api for REST API
module-oli for backend static process ..
regarding to doc (https://cloud.google.com/appengine/docs/php/modules/ and https://cloud.google.com/appengine/docs/php/modules/routing) I've created 3 .yaml config files:
dispatch.yaml
application: ABC
dispatch:
- url: "*/oli/*"
module: module-oli
- url: "*/"
module: module-api
app.yaml
application: ABC
version: v1
module: module-api
runtime: php55
api_version: 1
handlers:
- url: /.*
script: public/api.php
module-oli.yaml
application: ABC
version: v1
module: module-oli
runtime: php55
api_version: 1
manual_scaling:
instances: 1
handlers:
- url: /.*
script: public/oli.php
I also tried many changes in URL handling, but the error I always get is "Duplicate module: module-api".
Can you help me please? Thank you in advance ..
I have no idea why, but (on my computer) it does not work just from googleAppEngineLauncher.app (OSX 10.11.3, googleAppEngineLauncher version 1.9.32), but it works if I use command line tools:
dev_appserver.py app.yaml module-oli.yaml
and only if I do not use param --skip_sdk_update_check (does not matter value)
more about naming modules (and using default module or not) .. it all works even if I name default module with specific name (of course, it causes error when not all request are dispatched to the module).
more about dispatching to modules; it works (as it's documented here). of course, it does not work at local development environment, as every single module runs at a different port (than the dispatch does not work, and if there is a module with manual_scaling, the _ah/start can not be handled and as err500 it stops the start)
here are all setup files, and how to run it:
app.yaml
application: <APPLICATION-ID>
module: default
version: v1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: blablabla.php
module-oli.yaml
application: <APPLICATION-ID>
version: v1
module: module-oli
runtime: php55
api_version: 1
threadsafe: yes
instance_class: B1
manual_scaling:
instances: 1
handlers:
- url: /oli/.*
script: blebleble-oli.php
dispatch.yaml
dispatch:
- url: "*/oli/*"
module: module-oli
- url: "*/*"
module: default
to run on local development environment: dev_appserver.py app.yaml module-oli.yaml .. (no automatic routing, instances are running on different ports)
one everything is deployed to gcloud and dispatching is updated (appcfg.py -A wellfedcat-1221 update_dispatch .), it works like this:
APPLICATION-ID.appspot.com/* : served by default module ..
APPLICATION-ID.appspot.com/oli/* : served by module-oli ..
the dispatching is necessary when you want to use our own domain to map to gcloud ..
thank you #Tom for help!

Google Endpoints, the API explorer works locally but does not work after deployment

worked perfectly locally but the explorer is stuck in "Loading.." when deployed. Steps I took so far:
cleared browser cache
checked the logs, I have no errors and i DONT see a
"/_ah/spi/BackendService.getApiConfigs 200 " request, so thats a
issue and I dont know how to fix.
The link:
https://.appspot.com/_ah/spi/BackendService.getApiConfigs
results in: {"state": "APPLICATION_ERROR", "error_message": "Not
Found"}
Please point me in the right direction to debug this. thanks in advance
my app.yaml file
application: appID
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
# Endpoints handler
- url: /_ah/spi.*
script: the_api.APPLICATION
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /js
static_dir: static/js
- url: /.*
script: the_web_page.app
secure: always
libraries:
- name: webapp2
version: "2.5.2"
- name: endpoints
version: 1.0
- name: jinja2
version: latest
- name: pycrypto
version: latest
I had a simple error. To fix I changed the line
- url: /_ah/spi.*
in the app.yaml file to
- url: /_ah/spi/.*
what I find hard to explain is why the first worked in localhost.
I also had the yellow "Loading" status in my API Explorer on deployment and I was struggling to understand why - I had not changed any of my code but suddenly the API explorer stopped working.
All I did was to clear out my internet explorer temporary files, cookies and website data and it worked again.
This happens to me whenever I use Opera.i don't know if this is what you are using but try another browser.
Make sure you are using HTTPS. Endpoints in production only work using a secure connection.
It suddenly stopped working.
When I click on the Endpoint, it just change the url in the address bar of the browser but doesn't load it.
So I copied the url from the address bar and loaded the url directly and it worked.

Laravel 4 - Not working on Google App Engine

I'm trying to setup Laravel 4 with google app engine.
Here's the step on how I setup
Download laravel using composer following the docs step.
Create a app.yaml file with this
application: laraveldemo
version: 1
runtime: php
api_version: 1
handlers:
- url: /favicon\.ico static_files: public/favicon.ico upload: public/favicon\.ico
- url: /.* script: public/index.php
and start engine.
And thats what I get, following this http://blog.neoxia.com/laravel-4-on-google-appengine-for-php/
Seriously, I don't know what's the problem, it works fine with MAMP.
This problem is related to the 'native' session driver. You can switch you driver to 'cookie' and your app will run just fine.

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