2010-10-03 21:00:33 +00:00
|
|
|
module Guard
|
|
|
|
module Interactor
|
2011-05-06 17:29:24 +00:00
|
|
|
extend self
|
|
|
|
|
|
|
|
def run_all
|
|
|
|
::Guard.run do
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :run_all) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop
|
2011-05-13 20:05:58 +00:00
|
|
|
UI.info "Bye bye...", :reset => true
|
2011-05-06 17:29:24 +00:00
|
|
|
::Guard.listener.stop
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :stop) }
|
2011-05-06 20:58:18 +00:00
|
|
|
abort
|
2011-05-06 17:29:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reload
|
|
|
|
::Guard.run do
|
|
|
|
::Guard.guards.each { |guard| ::Guard.supervised_task(guard, :reload) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
def self.init_signal_traps
|
|
|
|
# Run all (Ctrl-\)
|
2011-04-24 17:21:39 +00:00
|
|
|
if Signal.list.has_key?('QUIT')
|
|
|
|
Signal.trap('QUIT') do
|
2011-05-06 21:35:09 +00:00
|
|
|
run_all
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-04-24 17:21:39 +00:00
|
|
|
else
|
|
|
|
UI.info "Your system doesn't support QUIT signal, so Ctrl-\\ (Run all) won't work"
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-05-06 17:29:24 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
# Stop (Ctrl-C)
|
2011-04-24 17:21:39 +00:00
|
|
|
if Signal.list.has_key?('INT')
|
|
|
|
Signal.trap('INT') do
|
2011-05-06 21:35:09 +00:00
|
|
|
stop
|
2011-04-24 17:21:39 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
UI.info "Your system doesn't support INT signal, so Ctrl-C (stop) won't work"
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-05-06 17:29:24 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
# Reload (Ctrl-Z)
|
2011-04-24 17:21:39 +00:00
|
|
|
if Signal.list.has_key?('TSTP')
|
|
|
|
Signal.trap('TSTP') do
|
2011-05-06 21:35:09 +00:00
|
|
|
reload
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-04-24 17:21:39 +00:00
|
|
|
else
|
|
|
|
UI.info "Your system doesn't support TSTP signal, so Ctrl-Z (Reload) won't work"
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
2011-04-24 17:21:39 +00:00
|
|
|
|
2010-10-03 21:00:33 +00:00
|
|
|
end
|
|
|
|
end
|
2011-05-06 17:29:24 +00:00
|
|
|
end
|