erichiggins / gaek

A collection of useful tools for Google App Engine.
MIT License
16 stars 6 forks source link

Adapt `gaek.environ` for use with Managed VMs #4

Closed erichiggins closed 4 years ago

erichiggins commented 8 years ago

The environment variables different when running Managed VMs, and the RPC stubs used by google.appengine.api.modules are not available. It would be beneficial for gaek to still function in this runtime environment as much as possible without throwing exceptions. Here's a dump of os.environ from a module running in Managed VMs with a custom image:

{
  'MEMCACHE_PORT_11211_TCP': 'tcp://172.17.0.3:11211',
  'SERVER_SOFTWARE': 'gunicorn/19.4.1',
  'MEMCACHE_PORT_11211_TCP_ADDR': '172.17.0.3', 
  'GAE_PARTITION': 's',
  'GAE_VM': 'true', 
  'MEMCACHE_NAME': '/gaeapp/memcache', 
  'HOME': '/root', 
  'GAE_MODULE_VERSION': 'vmv8', 
  'APPENGINE_LOADBALANCER_IP': '', 
  'MEMCACHE_PORT_11211_TCP_PORT': '11211', 
  'GAE_LONG_APP_ID': 'jt-calc', 
  'DEBIAN_FRONTEND': 'noninteractive', 
  'MEMCACHE_PORT': 'tcp://172.17.0.3:11211', 
  'MODULE_YAML_PATH': 'module.yaml', 
  'GAE_MINOR_VERSION': '389176423410002280', 
  'USE_MVM_AGENT': 'true', 
  'HTTP_X_APPENGINE_CURRENT_NAMESPACE': 'production', 
  'MEMCACHE_ENV_DEBIAN_FRONTEND': 'noninteractive', 
  'GAE_MODULE_NAME': 'mvm', 
  'GAE_APPENGINE_HOSTNAME': 'jt-calc.appspot.com', 
  'APPENGINE_LOADBALANCER': '', 
  'HOSTNAME': '90e692391545', 
  'GAE_AFFINITY': 'true', 
  'PWD': '/home/vmagent/app', 
  'GAE_MODULE_INSTANCE': '0', 
  'MEMCACHE_PORT_11211_TCP_PROTO': 'tcp',
# I injected this in the application init method based on GAE_MODULE_VERSION. 
  'CURRENT_VERSION_ID': 'vmv8',
# This was injected through my module.yaml file.
  'CURRENT_MODULE_ID': 'mvm', 
# These came from the Dockerfiles.
  'PORT': '8080', 
   'LANG': 'C.UTF-8', 
  'VIRTUAL_ENV': '/env', 
  'PKG_PATH': '/env/local/lib/python2.7/site-packages/', 
  'PATH': '/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 
  'SDK_VERSION': '1.9.30', 
  'SDK_URL': 'https://storage.googleapis.com/appengine-sdks/featured/google_appengine_1.9.30.zip', 
}
erichiggins commented 4 years ago

The structure of how GAE hosts apps has changed significantly since filing this and it's no longer relevant.