Sha256: 5c62e4b99aab98efa71a3467c6eb35ad1d1b875cbde1636d5a7f4bb768508edc

Contents?: true

Size: 710 Bytes

Versions: 22

Compression:

Stored size: 710 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}", merge_stderr: true)
    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

22 entries across 22 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.8 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.7 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.8 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.6 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.7 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.5 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.4 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.6 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.3 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.2 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.5 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.1 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.3.0 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.1.4 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.2.7 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.2.6 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.2.5 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.2.4 lib/kuber_kit/shell/commands/system_commands.rb
kuber_kit-1.2.2 lib/kuber_kit/shell/commands/system_commands.rb