Skip to content

Instantly share code, notes, and snippets.

@kany
Last active June 28, 2022 05:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kany/10494177 to your computer and use it in GitHub Desktop.
Save kany/10494177 to your computer and use it in GitHub Desktop.
Clearing dead/stuck/zombie Resque workers redis resque delayed_job

$ rails c

Loading development environment (Rails 3.1.3)
1.9.3p0 :002 > Resque::Worker.working.each{|w| w.done_working}

$ redis-cli

# Removes data from your connection's CURRENT database.
$ redis-cli FLUSHDB

# Removes data from ALL databases.
$ redis-cli FLUSHALL

# Show all redis keys
127.0.0.1:6379> KEYS *
1) "stat:failed"
2) "stat:processed"
3) "stat:processed:2020-11-19"
4) "processes"
5) "stat:failed:2020-11-19"
6) "a817a4a5dfe7:1:43796cd8705c"
7) "queues"
8) "dockerzon::cache:total_hits"

# View cache for a key
127.0.0.1:6379> GET dockerzon::cache:total_hits
"4"

Jobs in queue aren't processing, try this:

rake resque:work QUEUE='*'

Rails console:

[14] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> Resque.info
=> {:pending=>0,
 :processed=>1,
 :queues=>1,
 :workers=>0,
 :working=>0,
 :failed=>1,
 :servers=>["redis://localhost:6379/0"],
 :environment=>"test"}

# view queues
[15] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> Resque.queues
=> ["remote_content"]

# to work queue
[16] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> Resque::Worker.new('remote_content', {}).work

# to work 1 job in queue(if 3 jobs are pending, only 1 will complete)
[4] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_2>)> Resque::Worker.new('remote_content', {}).process
=> 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment