Skip to content

Instantly share code, notes, and snippets.

@brunoadacosta
Forked from johnallen3d/README.md
Created May 14, 2013 18:47
Show Gist options
  • Save brunoadacosta/5578402 to your computer and use it in GitHub Desktop.
Save brunoadacosta/5578402 to your computer and use it in GitHub Desktop.

Prune Resque Workers

There is an issue related to running Resque on Heroku and Resque's ability to clean it's state information for workers. This is mostly a cosmetic issue however we got to a point where the Resque Dashboard would timeout because it was trying to display hundreds of workers it thought were sitll running.

This is a heavy handed approach to cleaning up. We are finding any worker that was stared longer than a day ago and manually calling the unregister method. Be advised this will throw DirtyExit errors.

# heroku run console -a appname
days_ago = 1
Resque.workers.select { |w| Date.parse(w.started) < (Date.today - days_ago) }.each { |w| w.unregister_worker }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment