Skip to content

Commit f4ddbd7

Browse files
committed
Different load for Rails
Directly taken from gzigzigzeo#41 There's a potential issue with the initialization that prevents the config to be correctly loaded when in Rails. This enforces the right timing
1 parent 0c68a93 commit f4ddbd7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/sidekiq/grouping.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,8 @@ def start!
5757
end
5858
end
5959

60-
Sidekiq::Grouping.start! if Sidekiq.server?
60+
if defined?(Rails)
61+
require "sidekiq/grouping/railtie"
62+
else
63+
Sidekiq::Grouping.start! if Sidekiq.server?
64+
end

lib/sidekiq/grouping/railtie.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
module Sidekiq
4+
module Grouping
5+
class Railtie < ::Rails::Railtie
6+
config.after_initialize do
7+
Sidekiq::Grouping.start! if Sidekiq.server?
8+
end
9+
end
10+
end
11+
end

0 commit comments

Comments
 (0)