Search code examples
rediscapistranosidekiq

How to remove sidekiq specific redis cache via capistrano prior to a restart


On rails code deployment, sidekiq is re-started and we would like to remove the sidekiq specific redis cache from the instance before it re-starts.

This is what we want to achieve 1. sidekiq:stop 2. connect to remote redis pointed to by sideiq 3. select database (say select 1). 3. remove cache (say flushall)

How should I automate this via capistrano.


Solution

  • You can flush Sidekiq queues by calling them directly, or in their own Rake Task in your Step #3

     Sidekiq::ScheduledSet.new.clear #clear the scheduled queue..
     Sidekiq::RetrySet.new.clear #clear any quequed retries.