summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-11-01 00:37:13 -0700
committerStan Hu <stanhu@gmail.com>2016-11-01 07:03:25 -0700
commitcde3963dae470b1c785b142851ed870355ecc67b (patch)
tree574f447f67b869032f45db30e7ad3c410857a9e5
parent51f303967c7bd86066cb879058d1344e5872eb0f (diff)
downloadgitlab-ce-sh-init-sidekiq-queues.tar.gz
Initialize Sidekiq with the list of queues used by GitLabsh-init-sidekiq-queues
The Sidekiq client API adds an entry to the Sidekiq "queues" list, but mail_room and gitlab-shell use redis-rb directly to insert jobs into Redis and thus do not make an extra "sadd" call to Redis each time a job is inserted. To make it possible to monitor these queues via the API, add an initialization step to set up the list at startup. Closes gitlab-com/infrastructure#682
-rw-r--r--CHANGELOG.md1
-rw-r--r--config/initializers/sidekiq.rb16
2 files changed, 17 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 498eac9a289..b6c833ad030 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,6 +39,7 @@ Please view this file on the master branch, on stable branches it's out of date.
- Fix Sign in page 'Forgot your password?' link overlaps on medium-large screens
- Show full status link on MR & commit pipelines
- Fix documents and comments on Build API `scope`
+- Initialize Sidekiq with the list of queues used by GitLab
- Refactor email, use setter method instead AR callbacks for email attribute (Semyon Pupkov)
- Shortened merge request modal to let clipboard button not overlap
- In all filterable drop downs, put input field in focus only after load is complete (Ido @leibo)
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index f7e714cd6bc..0455a98dbfe 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -42,3 +42,19 @@ end
Sidekiq.configure_client do |config|
config.redis = redis_config_hash
end
+
+# The Sidekiq client API always adds the queue to the Sidekiq queue
+# list, but mail_room and gitlab-shell do not. This is only necessary
+# for monitoring.
+config = YAML.load_file(Rails.root.join('config', 'sidekiq_queues.yml').to_s)
+
+begin
+ Sidekiq.redis do |conn|
+ conn.pipelined do
+ config[:queues].each do |queue|
+ conn.sadd('queues', queue[0])
+ end
+ end
+ end
+rescue Redis::BaseError, SocketError
+end