lib/guard/rails/runner.rb in guard-rails-0.7.1 vs lib/guard/rails/runner.rb in guard-rails-0.7.2

- old
+ new

@@ -12,10 +12,16 @@ @root = options[:root] ? File.expand_path(options[:root]) : Dir.pwd end def start kill_unmanaged_pid! if options[:force_run] + + if options[:zeus] && !wait_for_zeus + UI.info "[Guard::Rails::Error] Could not find zeus socket file." + return false + end + run_rails_command! wait_for_pid end def stop @@ -63,10 +69,14 @@ def sleep_time options[:timeout].to_f / MAX_WAIT_COUNT.to_f end + def wait_for_zeus + wait_for_loop { File.exist?(zeus_sockfile) } + end + private # command builders def build_options rails_options = [ @@ -136,28 +146,26 @@ end } nil end - private - def wait_for_pid - wait_for_pid_loop { has_pid? } + wait_for_loop { has_pid? } end def wait_for_no_pid - wait_for_pid_loop { !has_pid? } + wait_for_loop { !has_pid? } end def remove_pid_file_and_wait_for_no_pid - wait_for_pid_loop do + wait_for_loop do FileUtils.rm pid_file, force: true !has_pid? end end - def wait_for_pid_loop + def wait_for_loop count = 0 while !yield && count < MAX_WAIT_COUNT wait_for_pid_action count += 1 end @@ -178,9 +186,13 @@ def read_pid Integer(File.read(pid_file)) rescue ArgumentError nil + end + + def zeus_sockfile + File.join(@root, '.zeus.sock') end end end end