Skip to content

Instantly share code, notes, and snippets.

@avidas
Last active August 30, 2017 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avidas/1e03a4ab83fa0d8a747b9b513ae49fb4 to your computer and use it in GitHub Desktop.
Save avidas/1e03a4ab83fa0d8a747b9b513ae49fb4 to your computer and use it in GitHub Desktop.
REVENG-149 Clear Redis variables set for running Sidekiq cron jobs
# JIRA: REVENG-149
# Remove Sidekiq enterprise schedules so late payment notices do not get sent
#
# When Sidekiq enterprise creates a cron job, it sets the keys loop-UNIQUE-ID, loops-UNIQUE-ID
# This keys are not getting cleaned up from Redis when we remove the cron jobs from codebase
# and restart sidekiq and app servers.
require 'sidekiq/api'
begin
# Get sidekiq loop keys from redis
sidekiq_loop_keys = Sidekiq.redis { |conn| conn.keys }.select{ |key| key[/loop-|loops-/] }
Rails.logger.info sidekiq_loop_keys
# Pass the keys for deletion to sidekiq. del will return how many keys got deleted.
result = Sidekiq.redis { |conn| conn.del(*sidekiq_loop_keys) }
# We are expecting to delete 1 or more keys
raise "No Redis keys got deleted" if result < 1
end
@sagross
Copy link

sagross commented Aug 30, 2017

please add the link to the JIRA here. Also, is this deleting all the keys, or just the keys for late payment notices?

@avidas
Copy link
Author

avidas commented Aug 30, 2017

@avidas
Copy link
Author

avidas commented Aug 30, 2017

@sagross late payment notices are the only cron jobs on sidekiq for spaceman so no other jobs will be impacted.

@sagross
Copy link

sagross commented Aug 30, 2017

๐Ÿ‘

@itai-katz
Copy link

๐Ÿ‘

@itai-katz
Copy link

๐Ÿ‘

@sagross
Copy link

sagross commented Aug 30, 2017

๐Ÿ‘

@jhjwind
Copy link

jhjwind commented Aug 30, 2017

๐Ÿ‘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment