I've recently deployed some A/B testing experiments using vanity to my heroku instance. However, whenever I access the dashboard i.e. /vanity The following error shows up in the logs
- ActionView::Template::Error (Connection refused - Unable to connect to Redis on 127.0.0.1:6379):
- 1: <ul class="experiments">
- 2: <% experiments.sort_by { |id, experiment| experiment.created_at }.reverse.each do |id, experiment| %>
- 3: <li class="experiment <%= experiment.type %>" id="experiment_<%=vanity_h id.to_s %>">
- 4: <%= render :file => Vanity.template("_experiment"), :locals => { :id => id, :experiment => experiment } %>
- 5: </li>
-
However, the redis to go url seems to be set up correctly and vanity seems to be able to access it e.g.
irb(main):011:0> Vanity.playground.connection
=> redis://bluegill.redistogo.com:9231/0
Anyone know what I could be doing wrong ?
my vanity.rb config file is fairly standard
development:
adapter: redis
connection: redis://localhost:6379/0
qa:
adapter: redis
connection: <%= ENV["REDISTOGO_URL"] %>
staging:
adapter: redis
connection: <%= ENV["REDISTOGO_URL"] %>
production:
adapter: redis
connection: <%= ENV["REDISTOGO_URL"] %>
and also the ENV["REDISTOGO_URL"] seems correct
irb(main):012:0> ENV["REDISTOGO_URL"]
=> "redis://redistogo:[email protected]:9231/"
And I can access Redis from the rest of the app, it just seems that Vanity is not picking it up for this template..
Ok, I've figured this one out. When we fork with unicorn I wasn't reconnecting to the correct redis server and instead defaulting to the localhost. This code snippet in unicorn.rb sorts it out.
I'm sure its similar for other forking servers too.