Skip to content

Commit

Permalink
Fix sidekiq initializer configuration; add sidekiq web dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic committed Mar 30, 2013
1 parent 01761f6 commit 768088c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
6 changes: 0 additions & 6 deletions scrolls/redis.rb
Expand Up @@ -18,12 +18,6 @@
end
$redis = Redis.new($redis_config)
if $redis_config[:password]
$redis_url = "redis://:#{$redis_config[:password]}@#{$redis_config[:host]}:#{$redis_config[:port]}/0"
else
$redis_url = "redis://#{$redis_config[:host]}:#{$redis_config[:port]}/0"
end
RUBY

if scroll? "eycloud_recipes_on_deploy"
Expand Down
28 changes: 25 additions & 3 deletions scrolls/sidekiq.rb
@@ -1,9 +1,16 @@
gem "sidekiq"
# slim/sinatra are used for the sidekiq monitoring UI at /sidekiq/SECRET
gem "slim"
gem "sinatra", ">= 1.3.0", require: false

initializer "sidekiq.rb", <<-RUBY
Sidekiq.configure_server do |config|
config.redis = { url: $redis_url }
if $redis_config[:password]
redis_url = "redis://:\#{$redis_config[:password]}@\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
else
redis_url = "redis://\#{$redis_config[:host]}:\#{$redis_config[:port]}/sidekiq"
end
Rails.logger.info "Setting sidekiq redis: \#{{ url: redis_url, namespace: 'sidekiq' }.inspect}"
Sidekiq.redis = { url: redis_url, namespace: 'sidekiq' }
RUBY

if scroll? "eycloud_recipes_on_deploy"
Expand All @@ -15,6 +22,16 @@
RUBY
end

after_bundler do
route <<-RUBY
require "sidekiq/web"
mount Sidekiq::Web, at: "/sidekiq/#{config['sidekiq_admin_secret']}"
require "sidekiq/api"
match "queue-status" => proc { [200, {"Content-Type" => "text/plain"}, [Sidekiq::Queue.new.size < 100 ? "OK" : "UHOH" ]] }
RUBY

end

__END__

name: Sidekiq
Expand All @@ -26,4 +43,9 @@
tags: [worker,background-tasks]

requires: [redis]
run_after: [redis, eycloud_recipes_on_deploy]
run_after: [redis, eycloud_recipes_on_deploy, cf]

config:
- sidekiq_admin_secret:
type: string
prompt: "Enter a secret string for the route /sidekiq/SECRET:"

0 comments on commit 768088c

Please sign in to comment.