I'm running a dev server using dev_appserver.py on google app engine via cloud shell.
I'm doing so just like the tutorial for a first app says.
But with my own Flask app that delivers static files (index.html + some js and css).
It runs fine, but after I terminate it using ctrl+c, I can still access it using Web Preview.
The problem is, when I want to launch the same app with some changes, It does not change what Web Preview shows.
Things I tried:
I looked for open processes using ps. Restarted the shell using Restart.
Made sure the files are actually changed using the shell.
Cleared cached data on local browser. Used different browser.
Used --port option to launch the app with a different port. It worked fine but now I have 2 servers running.
If I change the code before I terminate the dev_appserver script in the first place, it detects the changes and they are committed. After I terminate it it does not change even if I call dev_appserver again.
It may be that I don't actually understand what dev_appserver does? Maybe the Flask code itself still runs somehow? But how can I access it?
app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: server.app
libraries:
- name: flask
version: 0.12
As I suspected, this has nothing to do with dev_appserver.py
The problem somehow is still cache.
I went to the site through my phone and saw that the request was actually sent.
So I added app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 to my Flask app,
started the server on a new port, and it now works as it should.
Related
I am using Google App Engine to deploy a node app (nextjs, node-12).
To deploy the app, I run:
gcloud app deploy
My app.yaml is as follows (minus variable substitutions):
runtime: nodejs12
env_variables:
NEXT_PUBLIC_FRONTEND_URL: "A"
In my code is the following line:
const url = `${process.env.NEXT_PUBLIC_FRONTEND_URL}/login/callback`;
When this code runs in app engine, url evaluates to B/login/callback
I don't understand this behavior. The documentation here (https://cloud.google.com/appengine/docs/standard/nodejs/config/appref) seems to indicate to me that this should work, but it does not.
Is there a reason for this? I've unset the variables from my local computer, just in case they were somehow getting passed, and I removed the .env file in case nginx was sourcing it or something like that.
What you have done looks correct. Try the following troubleshooting steps
Confirm you are not directly setting the value somewhere in your code e.g. say you call a child process and pass an env to it and you have explicitly set the value there
Check your deployed versions (you can do this via cloud console, see path below). Do you have multiple versions of the app? Which one are you running?
To check your versions and which one is running
console.cloud.google.com > App Engine > Versions
To view the configuration for each of the deployed versions,
select the version and click on 'View' under the 'config' column . This will display the deployed app.yaml file for that version
I am deploying a app engine application through cloud shell. I have deployed it a lot of times, but currently when ever I deploy it i gets hanged at the below position and nothing happens:
myname#cloudshell:~stackdriver-metrics-export/list_metrics (my-project)$ gcloud app deploy
Services to deploy:
descriptor: [/home/myname/stackdriver-metrics-export/list_metrics/app.yaml]
source: [/home/myname/stackdriver-metrics-export/list_metrics]
target project: [my-project]
target service: [list-metrics]
target version: [20200703t225313]
target url: [http://list-metrics.my-project.uc.r.appspot.com]
Do you want to continue (Y/n)? Y
Beginning deployment of service [list-metrics]...
// it gets stuck here and nothing happens afterwards I even restarted cloudshell lot of times but the same result, there is no change in the cursor position also. No error is also thrown
Please help me as i am new to cloud shell and google cloud.
This is working now, I am not sure what is the reason, but after i try to download a project from cloudshell to my local machine, strangely I found the project in one of the cloud shell directories itself as duplicate, and I have cleaned all of that, so still not sure of the reason
Check if you have symbolic link or very large file in the same directory. That will cause the system to take along time packaging your deployment.
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.
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.
Purely for fun I've written a tiny http server in C and using the c buildpack listed on the heroku docs, I've got it building a binary in heroku, and I can run it fine via "heroku run ./httpd 52132" It logs to the console "Starting httpd.." etc as expected but I obviously can't access it because thats a worker dyno, not a web dyno so isn't routed to.
My problem comes with I add a Procfile containing "web: ./httpd $PORT" - Heroku says its launched it, heroku ps shows its running but the requests timeout, and the application log never logs any messages from the app (I don't see Starting httpd...)
So in theory its running, but not running.... I'm confused.
As I said, it works when I don't run it via the procfile for web :(!!
Any ideas? (I know this is kind of niche!)
Thanks