Skip to content
This repository
Browse code

Fix sidekiq initializer configuration; add sidekiq web dashboard

  • Loading branch information...
commit 768088c4a77883eb268b77893ee0e37050325d7f 1 parent 01761f6
Dr Nic Williams authored March 30, 2013
6  scrolls/redis.rb
@@ -18,12 +18,6 @@
18 18
 end
19 19
 
20 20
 $redis = Redis.new($redis_config)
21  
-
22  
-if $redis_config[:password]
23  
-  $redis_url = "redis://:#{$redis_config[:password]}@#{$redis_config[:host]}:#{$redis_config[:port]}/0"
24  
-else
25  
-  $redis_url = "redis://#{$redis_config[:host]}:#{$redis_config[:port]}/0"
26  
-end
27 21
 RUBY
28 22
 
29 23
 if scroll? "eycloud_recipes_on_deploy"
28  scrolls/sidekiq.rb
... ...
@@ -1,9 +1,16 @@
1 1
 gem "sidekiq"
  2
+# slim/sinatra are used for the sidekiq monitoring UI at /sidekiq/SECRET
  3
+gem "slim"
  4
+gem "sinatra", ">= 1.3.0", require: false
2 5
 
3 6
 initializer "sidekiq.rb", <<-RUBY
4  
-Sidekiq.configure_server do |config|
5  
-  config.redis = { url: $redis_url }
  7
+if $redis_config[:password]
  8
+  redis_url = "redis://:\#{$redis_config[:password]}@\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
  9
+else
  10
+  redis_url = "redis://\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
6 11
 end
  12
+Rails.logger.info "Setting sidekiq redis: \#{{ url: redis_url, namespace: 'sidekiq' }.inspect}"
  13
+Sidekiq.redis = { url: redis_url, namespace: 'sidekiq' }
7 14
 RUBY
8 15
 
9 16
 if scroll? "eycloud_recipes_on_deploy"
@@ -15,6 +22,16 @@
15 22
   RUBY
16 23
 end
17 24
 
  25
+after_bundler do
  26
+  route <<-RUBY
  27
+require "sidekiq/web"
  28
+  mount Sidekiq::Web, at: "/sidekiq/#{config['sidekiq_admin_secret']}"
  29
+  require "sidekiq/api"
  30
+  match "queue-status" => proc { [200, {"Content-Type" => "text/plain"}, [Sidekiq::Queue.new.size < 100 ? "OK" : "UHOH" ]] }
  31
+RUBY
  32
+
  33
+end
  34
+
18 35
 __END__
19 36
 
20 37
 name: Sidekiq
@@ -26,4 +43,9 @@
26 43
 tags: [worker,background-tasks]
27 44
 
28 45
 requires: [redis]
29  
-run_after: [redis, eycloud_recipes_on_deploy]
  46
+run_after: [redis, eycloud_recipes_on_deploy, cf]
  47
+
  48
+config:
  49
+  - sidekiq_admin_secret:
  50
+      type: string
  51
+      prompt: "Enter a secret string for the route /sidekiq/SECRET:"

0 notes on commit 768088c

Please sign in to comment.
Something went wrong with that request. Please try again.