I'm unable to serve static content from static_dir (css). when I visited the URL http://srvc1.appeng-vj.appspot.com/styles/index.htmll I get 404 Page Not Found error... I had expected the static content, index.html, from static_dir css should have been served as per app.yaml handlers!
app.yaml as follows:
runtime: python
env: flex
runtime_config:
python_version: 3
handlers:
- url: /styles
static_dir: css
- url: /s1/
script: home.application
entrypoint: gunicorn -b :$PORT m1:application
service: srvc1
app root directory structure is as follows (attach screenshot)
Thanks for any clue what might be wrong here !
Serving static files with static_dir is a GAE-Standard capability. It's able to do that because it is VERY different from GAE-Flexibile (which you appear to be using).
See the GAE-Flexible doc for "Serving Static Files": it doesn't say anything at all about using static_dir. For GAE-Flexible, it says your options are "You can serve static content directly from your application, host it on Cloud Storage, or use a third-party content delivery network".
Related
I have two application that I want to deploy with Google Cloud App Engine.
One of them is react front end, and I want to serve this through www.videoo.io
Second one is back-end, which will be served via api.videoo.io
Frontend yaml file react.yaml :
runtime: nodejs16
env: standard
handlers:
- url: /static
static_dir: static
secure: always
- url: www.videoo.io/*
service: frontend
script: auto
secure: always%
API yaml file, api.yaml :
runtime: python37
entrypoint: gunicorn -b :$PORT videoo.wsgi
service: "videoo-api"
env: standard
handlers:
- url: api.videoo.io/*
service: backend
script: auto
secure: always%
Is this the correct way to achieve this ?
What is the best strategy to serve these two separate applications that will interactively communicate (Frontend will make calls to API to get object information that is stored Django app) ?
Here is also my domain name information in Google App Engine settings :
You are on the right path. You are using the microservices architecture which is basically deploying individual apps as parts (services) under a single project.
Your frontend service seems to be your default so you don't need a service name for it. Every GAE App needs a default service.
Rename react.yaml to app.yaml (since it will be your default service) and update the contents to
runtime: nodejs16
env: standard
handlers:
- url: /static
static_dir: static
secure: always
- url: /.*
script: auto
secure: always
Also rename your api.yaml to backend.yaml since that is what you called your service (not sure if this is required but I do that to easily track of what is controlling my service). Update the contents of the file to
service: backend
runtime: python37
entrypoint: gunicorn -b :$PORT videoo.wsgi
env: standard
handlers:
- url: /.*
script: auto
secure: always
You'll need a dispatch.yaml file to route traffic to the different services. Something like
dispatch:
# Send all api traffic to the backend service.
- url: "api.videoo.io/*"
service: backend
# Send all other traffic to the default (frontend).
- url: "*/*"
service: default
Final step is that during your deploy, you will deploy the 2 services in addition to your dispatch.yaml file. The dispatch.yaml file has to be in your project root folder
gcloud app deploy app.yaml dispatch.yaml <path_to_backend.yaml>
When trying to visit the homepage of my website bob.com (just an example), I expect index.html to get displayed. Instead, I got a 404.
To reach index.html, I got to manually browse bob.com/index.html.
What did I do wrong with my current app.yaml ?
runtime: php
env: flex
runtime_config:
document_root: ./index.html
handlers:
# Handle the main page by serving the index page.
# Note the $ to specify the end of the path, since app.yaml does prefix matching.
- url: /*
static_files: index.html
upload: index.html
This has done the trick:
runtime: php
env: flex
runtime_config:
document_root: .
front_controller_file: index.html
I have been trying to deploy my project on Google Cloud SDK since yesterday and have been getting the same error over and over.
My app.yaml file looks like:
runtime: python27
api_version: 1
threadsafe: yes
- url: /
static_files: bin/index.html
upload: bin/index.html
- url: /assets
static_dir: bin/assets
- url: /src
static_dir: bin/src
- url: /vendor
static_dir: bin/vendor
- url: /templates-app.js
static_files: static/templates-app.js
upload: static/templates-app.js
- url: /templates-common.js
static_files: static/templates-common.js
upload: static/templates-common.js
- url: .*
script: main.app
I use this command to deploy:
gcloud preview app deploy app.yaml --version 1 --promote --force
And I get this error:
Beginning deployment...
Copying files to Google Cloud Storage...
Synchronizing files to [gs://staging.myapp.appspot.com/].
Updating module [default]...failed.
ERROR: (gcloud.preview.app.deploy) Error Response: [13] An internal error occurred.
I got the same error today Error Response: [13] An internal error occurred.
In my case, the issue was because I have a folder that has over 1000 files. Once I moved some of these files elsewhere, the internal error message disappeared!
I tried 1000 files in one folder, and it worked, then, I added one file (1001 files total) in the same folder, and the same internal error came back. It seems that it is kind of a limit that google app engine has 1000 files per folder.
I notice you don't have your app name in the app.yaml file and you also don't specify it in the upload cmd. I'd suggest making a habit in providing as much as the info as possible in the app.yaml to minimize the chances of human error. You can also specify the version in the app.yaml as well. This habit will help when you'll get to multi-modules apps, where such info is mandatory. See examples in the modules config doc.
From a different prospective, I saw several reports in which gcloud preview app deploy tripped, you can always try alternate approaches to rule out such cases, see my answer to this Q&A: Google App Engine deploy with Django module after gcloud update?
It ended up being the reportlab python library in the lib folder.
I found inserting it as a zip file rather than a normal folder worked.
import sys
sys.path.insert(0, 'reportlab.zip')
import reportlab
...
I have no idea why it wouldn't work. But I remember seeing something about a file limit when uploading projects with app-engine. Deploying 1 zip file is better than 181 files that make up reportlab.
I have a ready php website. For that website I am writing app.yaml for google app engine.
I read so many answers but it doesnt help me.
I am facing problem with php files under various subfolders in libraries folder.
In index.php, i accept rss feed url and process it for full text feed by calling other php files. but getting this error.
/makefulltextfeed.php?url=https%3A%2F%2Fnews.google.co.in%2Fnews%3Fpz%max
=10&links=preserve&exc=&submit=Create+Feed was not found on this server.
How to write app.yaml for all php files which comes under various sub-folders??
Do i have to write handlers: for all individual php files??
I am stuck here for whole day.
I am new to this topic. So if you find this as stupid question please forgive me.
Here is my app.yaml
application: xxxx-xxxx-90212
version: alpha-001
runtime: php
api_version: 1
handlers:
- url: /
script: index.php
- url: /config
script: config.php
- url: /makefulltextfeed
script: makefulltextfeed.php
- url: /css
static_dir: css
- url: /js
static_dir: css
- url: /images
static_dir: images
I have php files in subfolder. How to write app.yaml for that.
As described here you can use this notation to match all root path, that ends with .php, to a php script
# Serve php scripts.
- url: /(.+\.php)$
script: \1
This config assume that each your URL ends with .php, you can modify url regex to catch all urls (I test only the regex but I think it's works :) )
# Serve ALL php scripts.
- url: /((.+\/).*)$
script: \1.php
Or you can simulate httpd mod_rewrite as described here.
I am trying to host a simple static website on Google AppEngine, but I have a problem with setting up a custom 404 page.
My app.yaml serves static files (from www subdir) for all requests:
application: id
version: v
runtime: python27
api_version: 1
default_expiration: "1d"
threadsafe: yes
handlers:
- url: (.*)/
static_files: www\1/index.html
upload: www/index.html
- url: /
static_dir: www
error_handlers:
- file: 404.html
but while trying to access a file that does not exist, I do not see the 404.html, but the default GAE error message.
Logs show:
Static file referenced by handler not found: www/does-not-exists/index.html
or
Static file referenced by handler not found: www/does-not-exists.html
What am I doing wrong?
This won't work. You static handler will match most things, and you can not do a error_handler for a 404.
I ran into this error as well, and I basically caught it by using an base exception handler (I was using spring, so this was easy) to catch all exceptions (that weren't caught already) to redirect to an error page.