From 88b32c79cd65c5b86ee7f11a164341fabc7ada3b Mon Sep 17 00:00:00 2001 From: Connor Dunn Date: Tue, 10 Jun 2014 16:52:26 -0700 Subject: [PATCH 1/2] Don't use the KEYS command in redis. This command is dangerous and often disabled. --- lib/sidetiq/schedulable.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sidetiq/schedulable.rb b/lib/sidetiq/schedulable.rb index c7df814..778e97f 100644 --- a/lib/sidetiq/schedulable.rb +++ b/lib/sidetiq/schedulable.rb @@ -58,7 +58,7 @@ module Sidetiq end def get_schedulable_keys - schedulable_redis.keys("sidetiq:#{name}:*") + %w(next last schedule_description history).map { |key| "sidetiq:#{name}:#{key}" } end def get_schedulable_key(key) From 2556541d23bc59690afee7d39e8cd38854bac8b3 Mon Sep 17 00:00:00 2001 From: Connor Dunn Date: Tue, 10 Jun 2014 17:09:41 -0700 Subject: [PATCH 2/2] Don't crash when using KEYS in sidetiq/web. --- lib/sidetiq/views/locks.erb | 5 ++++- lib/sidetiq/web.rb | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/sidetiq/views/locks.erb b/lib/sidetiq/views/locks.erb index bf7320d..de15b8f 100644 --- a/lib/sidetiq/views/locks.erb +++ b/lib/sidetiq/views/locks.erb @@ -13,6 +13,7 @@ <%= erb File.read(File.join(view_path, '_home_nav.erb')) %>
+ <% if @locks_available %> <% if @locks.length > 0 %> @@ -44,7 +45,9 @@ <% else %>
No locks set.
<% end %> - + <% else %> +
KEYS command is disabled in your redis instance, lock information is not available.
+ <% end %> diff --git a/lib/sidetiq/web.rb b/lib/sidetiq/web.rb index e8cbba4..7987a67 100644 --- a/lib/sidetiq/web.rb +++ b/lib/sidetiq/web.rb @@ -13,7 +13,12 @@ module Sidetiq end app.get "/sidetiq/locks" do - @locks = Sidetiq::Lock::Redis.all.map(&:meta_data) + begin + @locks = Sidetiq::Lock::Redis.all.map(&:meta_data) + @locks_available = true + rescue Redis::CommandError + @locks_available = false + end erb File.read(File.join(VIEWS, 'locks.erb')), locals: {view_path: VIEWS} end