简体   繁体   中英

rails / passenger: using environment variable for memcache server address

I am trying to set up our Rails app to pull the address of the memcache server from an environment variable (we have 2 'production' environments, one for testing and one for live, and hence can't have different environments files).

This is a Rails 2.3.11 app, not rails 3.

I have this in my environments/production.rb file:

config.cache_store = :mem_cache_store, ENV['MEMCACHE_SERVERS'] || 'localhost:11211'

If I fire up a Rails console and do:

Rails.cache.stats

I see that it is using the right one out of the environment variable (set in /etc/environments on our ubuntu servers).

But, if our actual running rails app fired up via passenger it is using localhost!

Does Passenger not use the environment or am I doing something else wrong?

If there is a better way of doing this of course I am open to suggestions!

Have you tried using the Apache directive SetEnv or the equivalent for your server? The environment is heavily modified for Apache sub-processes, of which Passenger is one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM