A little more research after a suggestion from the server admin has confirmed that I can’t see Apache environment variables with os.environ
in a WSGI interface. Instead, those are available through the request
object. Since I don’t yet have a request object when starting up the app, I had to find a new way to ID the instance.
My server admin suggested that he add a system environment variable that would hold the instance name. I can read those variables just fine. He did, I read it, and all is well. New code:
import os TIER = os.environ.get('TIER','') ## get the value of the TIER env variable if fqdn == 'dashdrum_laptop': ## laptop SERVER_ENVIRONMENT = 'Laptop' elif TIER == 'dev': ## dev server SERVER_ENVIRONMENT = 'DEV' elif TIER == 'qa': ## qa server SERVER_ENVIRONMENT = 'QA' elif TIER == 'prod': ## production server SERVER_ENVIRONMENT = 'PROD'
Note that I’m still using the fqdn to ID the laptop.
Comments are closed.