Module: Mirage::CLIBridge
- Included in:
- Runner
- Defined in:
- lib/mirage/client/cli_bridge.rb
Instance Method Summary collapse
Instance Method Details
#kill(pid) ⇒ Object
17 18 19 |
# File 'lib/mirage/client/cli_bridge.rb', line 17 def kill pid ChildProcess.windows? ? `taskkill /F /T /PID #{pid}` : `kill -9 #{pid}` end |
#mirage_process_ids(ports) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mirage/client/cli_bridge.rb', line 3 def mirage_process_ids ports mirage_instances = {} ["Mirage Server", "mirage_server", "mirage server"].each do |process_name| processes_with_name(process_name).each_line.collect { |line| line.chomp }.each do |process_line| pid = process_line.split(' ')[1] port = process_line[/port (\d+)/, 1] mirage_instances[port] = pid end end return mirage_instances if ports.first.to_s == "all" || ports.empty? Hash[mirage_instances.find_all { |port, pid| ports.include?(port.to_i) }] end |
#processes_with_name(name) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/mirage/client/cli_bridge.rb', line 21 def processes_with_name name if ChildProcess.windows? `tasklist /V | findstr "#{name.gsub(" ", '\\ ')}"` else IO.popen("ps aux | grep '#{name}' | grep -v grep | grep -v #{$$}") end end |