Simplify redis configuration code

parent 6f1de49a
Pipeline #152 passed with stage
in 51 seconds
......@@ -11,22 +11,10 @@ class PubRelay
include HTTP::Handler
class_getter redis = begin
uri = URI.parse(ENV["REDIS_URL"]? || "redis://localhost")
host = uri.host.to_s
port = uri.port || 6379
password = uri.password
if (path = uri.path) && path.size > 1
db = path[1..-1].to_i
else
db = 0
end
cfg = Sidekiq::RedisConfig.new(host, port, password: password, db: db)
Sidekiq::Client.default_context = Sidekiq::Client::Context.new(cfg)
# Make sidekiq use REDIS_URL
ENV["REDIS_PROVIDER"] = "REDIS_URL"
Redis::PooledClient.new(host, port, password: password, database: db)
end
class_getter redis = Redis::PooledClient.new(url: ENV["REDIS_URL"]?)
class_property(private_key) do
private_key_path = ENV["RELAY_PKEY_PATH"]? || File.join(Dir.current, "actor.pem")
......
require "./pub_relay"
require "sidekiq/cli"
ENV["REDIS_PROVIDER"] = "REDIS_URL"
cli = Sidekiq::CLI.new
server = cli.create
cli.run(server)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment