Sha256: b1d05989f240588567a6e5c5e20fe99d67f145e536c99e269d1d8d1c275c1a63

Contents?: true

Size: 690 Bytes

Versions: 43

Compression:

Stored size: 690 Bytes

Contents

class KuberKit::Shell::Commands::SystemCommands
  def kill_process(shell, pid)
    # we need to use kill command directly sometimes, 
    # because Process.kill doesn't kill processes created by system() call
    shell.exec!("kill -9 #{pid}")
    true
  rescue
    false
  end

  def find_pids_by_name(shell, name)
    shell
      .exec!("ps auxww | grep '#{name}' | grep -v 'grep' | awk '{print $2}'")
      .split("\n")
      .reject(&:empty?)
      .map(&:chomp)
      .map(&:to_i)
  rescue
    []
  end

  def get_child_pids(shell, pid)
    shell
      .exec!("pgrep -P #{pid}")
      .split("\n")
      .reject(&:empty?)
      .map(&:chomp)
      .map(&:to_i)
  rescue
    []
  end
end

Version data entries

43 entries across 43 versions & 1 rubygems

Version Path
kuber_kit-1.2.0 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.1 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.0.1 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.0.0 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.9 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.8 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.7 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.6 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.5 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.4 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.3 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.2 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.1 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.9.0 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.8 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.7 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.6 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.5 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.4 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-0.8.3 lib/kuber_kit/shell/commands/system_commands.rb