Skip to content

Commit

Permalink
feat: Add rake task to clear ActionCable jobs (#9307)
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnu-narayanan committed Apr 30, 2024
1 parent 2c3e7d6 commit 9057c86
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/tasks/sidekiq_tasks.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace :sidekiq do
desc "Clear ActionCableJobs from sidekiq's critical queue"
task clear_action_cable_broadcast_jobs: :environment do
queue_name = 'critical'
queue = Sidekiq::Queue.new(queue_name)
jobs_cleared = 0

queue.each do |job|
if job['wrapped'] == 'ActionCableBroadcastJob'
job.delete
jobs_cleared += 1
end
end

puts "Cleared #{jobs_cleared} ActionCableBroadcastJob(s) from the #{queue_name} queue."
end
end

0 comments on commit 9057c86

Please sign in to comment.