lib/pact/mock_service/cli/pidfile.rb in pact-mock_service-2.1.1.pre.alpha.2 vs lib/pact/mock_service/cli/pidfile.rb in pact-mock_service-2.2.0

- old
+ new

@@ -1,7 +1,6 @@ require 'fileutils' -require 'pact/mock_service/os' module Pact module MockService class CLI < Thor @@ -72,38 +71,26 @@ sleep_time = 0.1 while process_running? && tries < 100 sleep sleep_time tries += 1 end - raise "Process #{pid_from_file} not stopped after #{100 * sleep_time} seconds." if process_running? + raise "Process #{pid_from_file} not stopped after {100 * sleep_time} seconds." if process_running? end def kill_process if file_exists? begin - windows? ? windows_kill : kill_2 + `ps -ef | grep pact` + Process.kill 2, pid_from_file waitpid delete rescue Errno::ESRCH $stderr.puts "Process in PID file #{pidfile_path} not running. Deleting PID file." delete end else $stderr.puts "No PID file found at #{pidfile_path}, server probably not running. Use `ps -ef | grep pact` if you suspect the process is still running." end - end - - def windows? - Pact::MockService::OS.windows? - end - - def kill_2 - Process.kill 2, pid_from_file - end - - def windows_kill - cmd = "taskkill /f /pid #{pid_from_file}" - `#{cmd}` end end end end end