Skip to content

Commit

Permalink
Fix sidekiq web
Browse files Browse the repository at this point in the history
* add rack-session gem (needed by rack 3)
* update standalone code from https://github.com/sidekiq/sidekiq/wiki/Monitoring#standalone
* fix sidekiq_web service in docker-compose.yml
  • Loading branch information
aelkiss committed May 29, 2024
1 parent 93c9790 commit 3078966
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ gem "sequel"
gem "thor"
gem "zinzout"
gem "puma"
gem "rack-session"
gem "sidekiq"
gem "sidekiq-batch", git: "https://github.com/breamware/sidekiq-batch"

Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ GEM
nio4r (~> 2.0)
racc (1.8.0)
rack (3.0.11)
rack-session (2.0.0)
rack (>= 3.0.0)
rainbow (3.1.1)
rdoc (6.6.3.1)
psych (>= 4.0.0)
Expand Down Expand Up @@ -212,6 +214,7 @@ DEPENDENCIES
pry
puma
push_metrics!
rack-session
rgl
rspec
rspec-sidekiq
Expand Down
26 changes: 11 additions & 15 deletions bin/sidekiq_web.ru
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
require "sidekiq"
require "sidekiq/web"
require_relative "../config/initializers/sidekiq"

SESSION_KEY = ".session.key"

if !File.exist?(SESSION_KEY)
require "securerandom"
File.open(SESSION_KEY, "w") do |f|
f.write(SecureRandom.hex(32))
end
end
# This is sidekiq_web.ru
# Run with `bundle exec rackup sidekiq_web.ru` or similar.

Services.redis_config[:size] = 1

use Rack::Session::Cookie, secret: File.read(SESSION_KEY), same_site: true, max_age: 86400
require "securerandom"
require "rack/session"
require "sidekiq/web"

# In a multi-process deployment, all Web UI instances should share
# this secret key so they can all decode the encrypted browser cookies
# and provide a working session.
# Rails does this in /config/initializers/secret_token.rb
secret_key = SecureRandom.hex(32)
use Rack::Session::Cookie, secret: secret_key, same_site: true, max_age: 86400
run Sidekiq::Web
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ services:
<<: *holdings-container-defaults
restart: always
volumes:
- .:/usr/src/app
- gem_cache:/gems
- ./example/datasets:/tmp/datasets
command: bundle exec sidekiq -c 1 -r ./lib/sidekiq_jobs.rb

Expand Down

0 comments on commit 3078966

Please sign in to comment.