-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Pro Web UI
Mike Perham edited this page Sep 27, 2023
·
15 revisions
See the Monitoring page for basics on setting up Sidekiq"s Web UI. To activate the Sidekiq Pro web features, you must require it in your config/routes.rb
:
require "sidekiq/pro/web"
Your::Application.routes.draw do
mount Sidekiq::Web => "/sidekiq"
end
Sidekiq Pro can monitor multiple Sidekiq shards in a single web process. You must create a different connection pool for each shard and mount a different copy of the Web UI for each shard:
require "sidekiq-pro"
require "sidekiq/pro/web"
# Sidekiq Pro 4.x and 5.x
POOL1 = ConnectionPool.new { Redis.new(:url => "redis://localhost:6379/0") }
POOL2 = ConnectionPool.new { Redis.new(:url => "redis://localhost:6378/0") }
# Sidekiq Pro 7.x
POOL1 = Sidekiq::RedisConnection.create(url: "redis://localhost:6379/1")
POOL2 = Sidekiq::RedisConnection.create(url: "redis://localhost:6379/2")
mount Sidekiq::Web => "/sidekiq" # default
mount Sidekiq::Pro::Web.with(redis_pool: POOL1), at: "/sidekiq1", as: "sidekiq1" # shard1
mount Sidekiq::Pro::Web.with(redis_pool: POOL2), at: "/sidekiq2", as: "sidekiq2" # shard2
Rack example, in app.ru
, then run with bundle exec rackup app.ru
:
require "sidekiq-pro"
require "sidekiq/pro/web"
require "securerandom"
require "rack/urlmap"
require "pry"
# 4.x and 5.x
POOL1 = ConnectionPool.new(size: 5, timeout: 5) { Redis.new(url: "redis://redis_2:6379/0") }
POOL2 = ConnectionPool.new(size: 5, timeout: 5) { Redis.new(url: "redis://redis_3:6379/0") }
# 7.x
POOL1 = Sidekiq::RedisConnection.create(url: "redis://redis_2:6379/0")
POOL2 = Sidekiq::RedisConnection.create(url: "redis://redis_3:6379/0")
use Rack::Session::Cookie, secret: SecureRandom.hex(32), same_site: true, max_age: 86_400
run Rack::URLMap.new(
"/sidekiq" => Sidekiq::Web,
"/sidekiq1" => Sidekiq::Pro::Web.with(redis_pool: POOL1),
"/sidekiq2" => Sidekiq::Pro::Web.with(redis_pool: POOL2),
)