lib/guard/resque.rb in guard-resque-0.0.1 vs lib/guard/resque.rb in guard-resque-0.0.2
- old
+ new
@@ -11,41 +11,38 @@
# :verbose e.g. true
# :trace e.g. true
# :stop_signal e.g. KILL
def initialize(watchers = [], options = {})
@options = options
- @process = nil
@pid = nil
- @stop_signal = options[:stop_signal] || "TERM"
+ @stop_signal = options[:stop_signal] || "KILL"
super
end
def start
stop
UI.info "Starting up resque..."
- @process = IO.popen(cmd)
- @pid = @process.pid
+ UI.info cmd
+ @pid = spawn(cmd)
end
# Called on Ctrl-C signal (when Guard quits)
def stop
- if @process
+ if @pid
UI.info("Stopping resque...")
- ::Process.kill(@stop_signal, @process.pid)
+ ::Process.kill(@stop_signal, @pid)
::Process.waitpid(@pid) rescue Errno::ESRCH
- @process.close
@pid = nil
- UI.info("Stopped process #{@name}")
+ UI.info("Stopped process resque")
end
end
# Called on Ctrl-Z signal
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
def reload
UI.info "Restarting resque..."
- stop
- start
+ restart
end
# Called on Ctrl-/ signal
# This method should be principally used for long action like running all specs/tests/...
def run_all
@@ -53,9 +50,14 @@
end
# Called on file(s) modifications
def run_on_change(paths)
restart
+ end
+
+ def restart
+ stop
+ start
end
private
def cmd