Skip to content

Commit

Permalink
add logging comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashhas committed Oct 29, 2024
1 parent a63a74f commit c757d08
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions config/initializers/redis.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
# Initialize Redis connection
$redis = Redis.new(url: ENV['REDIS_URL'], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
Rails.logger.info("Redis initializer is being loaded")
Rails.logger.info("Redis URL: #{$redis.client.options[:url]}")
Rails.logger.info("SSL Params: #{$redis.client.options[:ssl_params]}")
begin
Rails.logger.info("Redis PING: #{$redis.ping}")
rescue StandardError => e
Rails.logger.error("Redis connection failed: #{e.message}")
end

# Log Redis connection details
Rails.logger.info("REDIS_URL: #{ENV['REDIS_URL']}")

# Conditional block to prevent Redis commands during asset precompilation
unless ENV['ASSET_PRECOMPILE']
# Log connection details if not in asset precompilation mode
Rails.logger.info("Redis URL: #{$redis.client.options[:url]}")
Rails.logger.info("SSL Params: #{$redis.client.options[:ssl_params]}")

# Test Redis connection with a PING command
begin
Rails.logger.info("Redis PING: #{$redis.ping}")
rescue StandardError => e
Rails.logger.error("Redis connection failed: #{e.message}")
end
end

0 comments on commit c757d08

Please sign in to comment.