Gracefully shutting down sidekiq processes
Use this to kill sidekiq forcefully. ps -ef | grep sidekiq | grep -v grep | awk ‘{print $2}’ | xargs kill -9
Use this to kill sidekiq forcefully. ps -ef | grep sidekiq | grep -v grep | awk ‘{print $2}’ | xargs kill -9
Go to Run/Debug Configurations Add a new Gem Command Enter ‘sidekiq’ as the Gem name and Executable name Check ‘Run the script in the contexst of bundle (bundle exec) under the ‘Bundler’ tab Click ‘Apply’ and then run it.
Mike Perham who wrote Sidekiq addressed this here: http://www.mikeperham.com/2009/05/25/memory-hungry-ruby-daemons/ tl;dr version: MRI will not give the memory back, the most you can do is control the heap, and to do that, Ruby Enterprise Edition was suggested. Don’t know that any of this helps, but that is the situation – straight from the horse’s mouth.
Here’s a way that you’ll likely need to modify to get the job you want (maybe like g8M suggests above), but it should do the trick: > job = Sidekiq::Queue.new(“your_queue”).first > job.klass.constantize.new.perform(*job.args) If you want to delete the job: > job.delete Tested on sidekiq 5.2.3.
Start: $ bundle exec sidekiq -d -P tmp/sidekiq.pid -L log/sidekiq.log where -d demonize, -P pid file, -L log file. Stop: $ bundle exec sidekiqctl stop tmp/sidekiq.pid 0 Sidekiq shut down gracefully. where 0 is number of seconds to wait until Sidekiq exits.
SidekiqWorker.new.perform Voila!
As of sidekiq 6.0.1, it is possible to pass the following to an ActiveJob worker to prevent it from retrying: class ExampleJob < ActiveJob::Base sidekiq_options retry: false def perform(*args) # Perform Job end end More information: https://github.com/mperham/sidekiq/wiki/Active-Job#customizing-error-handling EDIT: According to this this requires Rails 6.0.1 or later as well.
You use a separate global connection pool for your application code. Put something like this in your redis.rb initializer: require ‘connection_pool’ REDIS = ConnectionPool.new(size: 10) { Redis.new } Now in your application code anywhere, you can do this: REDIS.with do |conn| # some redis operations end You’ll have up to 10 connections to share amongst … Read more
This was related to a Ruby concurrency issue fixed in a patch for version 2.3 Your logs suggests your app is running 2.0.0. Updating the language version to at least the stable version of 2.3 would fix that problem. This can be easily done by changing your Gemfile Ruby declaration: ruby ‘2.3.8’
if you want to list all currently running jobs from console, try this workers = Sidekiq::Workers.new workers.each do |_process_id, _thread_id, work| p work end a work is a hash. to list all queue data. queues = Sidekiq::Queue.all queues.each do |queue| queue.each do |job| p job.klass, job.args, job.jid end end for a specific queue change this … Read more