I inherited a App Engine static-file-only service and I am still trying to understand it (contract developers, long gone, docs=0). One point that I am stuck on is why in the Debugger Source display I don't see the static file directory. This is a Python 2.7 app and to be clear there is no Python code provided. The app.yaml file looks like this:
service ya-da
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
static_files: dist/index.html
upload: dist/index.html
It is a SPA, so it just one html file and lots of bundled JS & CSS.
This is what I see in App Engine Debugger source display
So no dist directory is shown. But it is there as the app is running happily. There is nothing tucked into any other directory (most of them are utterly useless in the App Engine context) that would be the contents of dist.
So, the simple question is: why doesn't dist show up in the debugger?
given that you have found an issue related with the debugger, you can file an issue in the Public Issue Tracker of Google Cloud Platform with the components of Debugger Stackdriver here. In this way, the Stackdriver Engineers team have visibility of this issue and other users with the same issue can star it and follow it.
From your comment to my other answer, it seems you just need access to code that was deployed.
It looks like you are using GAE standard first generation so you should be able to download your code as described here. This is the command:
appcfg.py -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID] download_app [OUTPUT_DIR]
That page has deprecation warnings because Google is encouraging people to migrate to GAE second generation, but I expect that will work for you.
Your static files don't show up in the debugger because GAE treats static files very differently than it does your code.
The point of having static files is to be able to serve them without burdening your GAE instances. The app.yaml file has a an upload option because you are telling GAE where to put your static files, and this location is separate from where your code is uploaded.
The debugger is for debugging code. It is not possible to debug a static file because there is no code (Well, no server code. Your Javascript runs in the browser.) and there is nothing to debug.
What is it you are trying to accomplish? Your Javascript is running on the front end so you can't debug it on the backend.
Related
I'm using GCP App Engine with auto scaling.
If I deploy a new version of the app code (Python 3 Flask app) with a simple change for control and test purposes, lets say I add a comment to one of the .js files I am not seeing that change to the file in the browser after it has been deployed.
I have 100% of traffic being served by the new version of the app. When I look at the source code for the version I can see the comment in there, but when I clear my browser cache and visit the page I only ever get the old version of the page (without the comment in the .js).
I have tried using the --promote and --no-cache values in the app deploy command, but no use. I have added:
default_expiration: "0d 0h 0m 0s"
To the app.yaml
I have also turned on object versioning of the storage account which app engine uses to try to ensure that only a single version of the file is available to be served - still no use.
The command I'm using to deploy is:
run: "gcloud app deploy app.yaml --quiet --promote --no-cache"
I can't understand why it should be so difficult to simply deploy a new version of the app and have the app engine serve the latest files; I must be doing something wrong but cannot see what.
Would appreciate any pointers.
The files are cached (even if for a short while and sometimes it takes time to clear it).
The trick is to make the urls (for the static files) unique for each deployment. This way, the browser is loading a 'distinct' url after each deployment. For example, you could append the environment variable, CURRENT_VERSION_ID to the url for all static elements. This means having something like (assuming Python/Jinja2)
src="/static/js/my_js_file.js?{{CURRENT_VERSION_ID}}"
os.environ['CURRENT_VERSION_ID'] changes for each deployment. There's a possibility this attribute is not available in newer runtimes. If so, just dump the environment variables and look for an attribute that is always present but the value changes (e.g. GAE_INSTANCE).
You could also just generate a random number each time your App is deployed and use that instead i.e.
src="/static/js/my_js_file.js?{{RANDOM_NUMBER}}"
I have been working on a website and I decieded to use google app engine to host it. I have been able use the config file to try and deploy with no errors in the config. I am using the google cloud SDK to upload and deploy my files. Whenever I try to deploy the SDK says it is uploading 30,000 files. I only have 11 files I need to upload. I think the SDK is trying to upload itself to cloud storage. My website files are in a www subfolder under my public directory where the SDK is installed. On my old computer I was able to move all the SDK files to my home directory and use my public folder as the sourse. When I try to do that now it says gcloud is not found. I am using gcloud app deploy and running windows 11. My old computer was running windows 10. I am not sure if that matters. I am also not sure if I need to specify anything in my app.yaml file. If anyone could help that would be great.
This is my app.yaml file:
runtime: php74
handlers:
- url: /www/index.html
static_files: /www/index.html
upload: /www/index.html, /www/campsite-form-results.php, /www/contact_us.php
This is the command line screenshot:
Plese let me know if there is any other information need to add.
This is expected since gcloud will upload everything that is in the path where is the app.yaml file.
I suspect that C:/Users/evanh/public contains a lot of things (even hidden folders) and not only your files for the app.
Create a new folder and put there your code, then try to deploy the app from that new folder.
EDIT
Since this was the accepted answer I'm editing this to include John's suggestion using his answer:
As a good practice, create a .gcloudignore file and specify what you do not want uploaded. You can see more info here:
gcloud topic gcloudignore
Ignoring files
Create a .gcloudignore file and specify what you do not want uploaded otherwise everything is uploaded.
gcloud topic gcloudignore
Ignoring files
According to the docs found here:
https://cloud.google.com/appengine/docs/standard/php7/runtime#application_startup
My app, is able to serve up index.php, without defining any handlers in my app.yaml file, which it does. Great! However, that same app.yaml file fails to serve up index in my local environment (dev_appserver.py) That seems less than ideal...
The path to the file is public/index.php
Here's the error I see in my local when I go with the very same app.yaml that works perfectly in production:
The url "/" does not match any handlers.
The dev_appserver.py only works with the first generation App Engine runtimes.
As you can see on the documentation, to test locally your PHP 7 app, you have to use the development tools that you usually use.
On this thread from the Google’s Public Issue Tracker there is a similar issue, and there is posted a solution for locally test PHP 7 apps. Basically, you have to set up a front controller on a web server locally. You can do it following this tutorial, for example.
Although I started development for Google App Engine using Endpoints a while ago, I hadn't noticed this - Google's ref. page for Project structure says this:
Your development file hierarchy should look like this:
MyDir/
[pom.xml]
[build.gradle]
[index.yaml]
[cron.yaml]
[dispatch.yaml]
src/main/
appengine/
app.yaml
docker/
[Dockerfile]
java/
com.example.mycode/
MyCode.java
webapp/
[index.html]
[jsp.jsp]
WEB-INF/
[web.xml]
You'll need to define an app.yaml file that looks like this:
...
Note that the app.yaml is deemed compulsory as per the docs. In my case, I spawned a backend module(through the Wizard) in Android Studio that builds on Gradle. I have been able to build and deploy this module on GAE successfully but now I needed to switch from automatic scaling to basic/manual scaling, I found this to be done through app.yaml file.
Here is the thing: I don't have an app.yaml in place and it works fine. Where is then the config info. that GAE requires to deploy the App.
Specifically,
app.yaml specifies the environment - Java. But, I found the java plugin in build.gradle for that. Aren't 2 config places for the same thing confusing?
Is it possible to ditch app.yaml entirely for equivalent config. in build.gradle?
Why is Google claiming app.yaml to be compulsory when I am able to do without it?
The App Engine Java runtime uses its own configuration schema in XML, while others are YAML.
To set the scaling elements, follow the official reference.
There is another question on this but i didn't found it useful.
I've installed Google App Engine SDK 1.7 with Python 2.7 on Windows 7.
When i launch the app from the Google App Engine Launcher, i have this error in the logs
CouldNotFindModuleError
the entire log is here:
http://pastebin.com/EwbpMcx2
ok it could not find a module, but what module? how can i solve this?
my app is very simple, a hello world
app.yaml
application: alleudacity
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /.*
script: helloworld.py
helloword.py
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
It looks like you're using libraries elixir and paramiko which are not available by default on google app engine.
You can either not use them (good way to test if that's really the problem), or potentially if they are pure python libraries, install them in your actual project folder.
When you deploy to app engine, only files in your project folders are uploaded - libraries that installed elsewhere in your system won't be available. dev_appserver modifies your environment so that you see these failures locally, rather than having things work fine locally and break after you deploy.
I guess I misread the trace. You're missing some module. Looking at the google code, it should print out the name of the module you're missing. But since I don't see it, you could force a breakpoint right before where the error should be and see what the name of the missing module is. Force a breakpoint by editing the code (C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver_import_hook.py) and adding
import pdb
pdb.set_trace()