简体   繁体   中英

How do I get Vanity to connect to Elasticache instance

I am using the Vanity gem to do A/B testing and it works great locally.

On our EC2 instances rails refuses to start when Vanity is enabled.

I have been able to recreate the issue locally by providing incorrect details for my local Redis install.

I have tried several permutations of settings, the two that I would have expected to work are;

staging:
  adapter: redis
  connection: redis://my-name.id.0001.use1.cache.amazonaws.com:6379/0

And

staging:
  adapter: redis
  connection: redis://my-name.id.0001.use1.cache.amazonaws.com:6379

When I log onto the server I can run redis-cli -h my-name.id.0001.use1.cache.amazonaws.com and it connects immediately.

I am pretty sure this should work because this person was able to get something working with a Heroku setup (which just uses an external URL as I used above)

Error Message

Here is the error message I get when deploying the server. job_options.rb is my test experiment, it works fine in Development.

/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/base.rb:24:in `eval'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/base.rb:24:in `block in load'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/base.rb:22:in `instance_eval'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/base.rb:22:in `load'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/playground.rb:248:in `block in set_experiments'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/playground.rb:247:in `each'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/playground.rb:247:in `set_experiments'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/playground.rb:26:in `initialize'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/vanity.rb:133:in `new'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/vanity.rb:133:in `load!'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/vanity.rb:123:in `playground'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/adapters/redis_adapter.rb:219:in `rescue in call_redis_with_failover'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/adapters/redis_adapter.rb:216:in `call_redis_with_failover'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/adapters/redis_adapter.rb:105:in `set_experiment_created_at'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/base.rb:159:in `save'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/ab_test.rb:451:in `save'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/definition.rb:21:in `define'
/shared/bundle/ruby/2.2.0/gems/vanity-2.0.0/lib/vanity/experiment/ab_test.rb:571:in `ab_test'
./experiments/job_options.rb:1:in `new_binding'

Looks like this was a regression in Vanity 2.0, until a fix is released, you can just replace the connection key in the Vanity config with a url key, eg:

staging:
  adapter: redis
  url: redis://my-name.id.0001.use1.cache.amazonaws.com:6379/0

Those keys are passed through to the individual adapters and the ruby Redis client accepts url .

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