GAE API to find where the application works - local machine or gae cloud

I have a Google App application in which I want to work differently, depending on whether it works in the local local environment (for example, with dev_appserver.py), unlike the real GAE cloud.

I am currently using a flag variable, which I manually switch to achieve this. But I am sure that one day I will forget to change it and lead to a problem. So I would like to know if there is an API or any other way to find out where the GAE application works?

Thanks.

+7
google-app-engine
source share
3 answers

You can check the SERVER_SOFTWARE environment variable to see if it is Development / X or Google App Engine / X:

http://code.google.com/appengine/docs/python/runtime.html#The_Environment

+8
source share

I know the original question was for python, but use Java for this:

if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) { // running on prod } else { // running on dev } 
+1
source share

I use datastore.get () to pull values.

On dev_appserver, the data store contains an "Environment" object set to "local". In the GAE application, dev "environment" is "dev", In the GAE application, prod "Environment" is "prod"

You can go to UAT, etc.

0
source share

All Articles