Created
July 5, 2016 23:33
-
-
Save pnomolos/93cf6eca72d7095a10034ff7cf5cc3c1 to your computer and use it in GitHub Desktop.
Really simple resque-pool plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requires
resque-pool
to be tracked from master, due to use of the new--hot-swap
option.