Reputation: 13251
I rely on python's os.environ
to work out what configs my application should use (such as different API keys for different hosts).
It seems that bulkloader doesn't have access to these variables, is there anyway I can tell what the current version of my application or the current host is when bulkloader is running?
Usually I do this in my config_helper
:
env = os.environ[ 'CURRENT_VERSION_ID' ].split( '.' )[ 0 ]
And bulkloader has reported a KeyError regarding CURRENT_VERSION_ID
, so I used this:
if os.environ.get('HTTP_HOST'):
host = os.environ['HTTP_HOST']
else:
host = os.environ['SERVER_NAME']
if host is not None:
if host.find( 'locahost' ):
env = 'local'
elif host.find( 'prod-server' ):
env = 'prod'
elif host.find( 'dev-server' ):
env = 'dev'
elif host.find( 'stage-server' ):
env = 'stage'
os.environ[ 'CURRENT_VERSION_ID' ] = env + '.1'
However bulkloader complains that SERVER_NAME
is an invalid object meaning that it also can't find HTTP_HOST
.
Any other ideas?
Upvotes: 0
Views: 332
Reputation: 3436
Environment variables like HTTP_HOST and CURRENT_VERSION_ID are only available when your app is running as a web application.
Probably you can just pass the variables with env command as follows:
$ env CURRENT_VERSION_ID=local.1 bulkloader ....
Upvotes: 1