Skip to content

Instantly share code, notes, and snippets.

@pnomolos
Created July 5, 2016 23:33
Show Gist options
  • Save pnomolos/93cf6eca72d7095a10034ff7cf5cc3c1 to your computer and use it in GitHub Desktop.
Save pnomolos/93cf6eca72d7095a10034ff7cf5cc3c1 to your computer and use it in GitHub Desktop.
Really simple resque-pool plugin
require "guard/compat/plugin"
module ::Guard
class ResqueGuard < Plugin
def start
puts "Starting Resque"
@pid = spawn("bin/resque-pool --hot-swap")
Process.detach(@pid)
end
def reload
puts "Reloading Resque"
start
end
def stop
puts "Stopping resque"
Process.kill("TERM", @pid)
end
def run_all
reload
end
def run_on_modifications(paths)
return false if paths.empty?
reload
end
alias_method :run_on_additions, :run_on_modifications
alias_method :run_on_removals, :run_on_modifications
end
end
guard :resque_guard do
watch(%r{^lib/(.+)\.rb$})
watch(%r{^app/(.+)\.rb$})
end
@pnomolos
Copy link
Author

pnomolos commented Jul 5, 2016

Requires resque-pool to be tracked from master, due to use of the new --hot-swap option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment