class KuberKit::Shell::Commands::SystemCommands
Public Instance Methods
find_pids_by_name(shell, name)
click to toggle source
# File lib/kuber_kit/shell/commands/system_commands.rb, line 11 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
get_child_pids(shell, pid)
click to toggle source
# File lib/kuber_kit/shell/commands/system_commands.rb, line 22 def get_child_pids(shell, pid) shell .exec!("pgrep -P #{pid}") .split("\n") .reject(&:empty?) .map(&:chomp) .map(&:to_i) rescue [] end
kill_process(shell, pid)
click to toggle source
# File lib/kuber_kit/shell/commands/system_commands.rb, line 2 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