Last active
August 30, 2017 19:40
-
-
Save avidas/1e03a4ab83fa0d8a747b9b513ae49fb4 to your computer and use it in GitHub Desktop.
REVENG-149 Clear Redis variables set for running Sidekiq cron jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 late payment notices are the only cron jobs on sidekiq for spaceman so no other jobs will be impacted.
๐
๐
๐
๐
๐
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please add the link to the JIRA here. Also, is this deleting all the keys, or just the keys for late payment notices?