Ruby on Rails - Puma on_worker_boot connect with redis -
i'm trying connect redis on heroku using puma keep running error
read error: #<redis::cannotconnecterror: error connecting redis on 127.0.0.1:6379 (errno::econnrefused)>
i've searched stackoverflow none of answers seem fix issue.
my puma.rb
config
workers integer(env['web_concurrency'] || 2) threads_count = integer(env['max_threads'] || 5) threads threads_count, threads_count preload_app! rackup defaultrackup port env['port'] || 3000 environment env['rack_env'] || 'development' on_worker_boot activerecord::base.establish_connection redis.current.client.reconnect $redis = redis.current end
my redis.rb
initializer
$redis = redis.new(:url => env["rediscloud_url"])
i checked env["rediscloud_url"]
redis://rediscloud:blank@blank.eu-west-1-1.1.ec2.garantiadata.com:port
i can't figure out doing wrong, seems correct me
i had set config var heroku config:set redis_provider=rediscloud_url
puma.rb
workers integer(env['web_concurrency'] || 2) threads_count = integer(env['max_threads'] || 5) threads threads_count, threads_count preload_app! rackup defaultrackup port env['port'] || 3000 environment env['rack_env'] || 'development' on_worker_boot activerecord::base.establish_connection if env["rediscloud_url"] uri = uri.parse(env["rediscloud_url"]) redis.current = redis.new(host: uri.host, port: uri.port, password: uri.password) $redis = redis.current else redis.current.quit end end
redis.rb
if env["rediscloud_url"] uri = uri.parse(env["rediscloud_url"]) $redis = redis.new(host: uri.host, port: uri.port, password: uri.password) end
Comments
Post a Comment