generators/harvestable_model/templates/daemons_extension.rb
# Find UNIX pids based on app_name.  CAUTION: This has only been tested on
# Mac OS X and CentOS.
Find UNIX pids based on app_name.  CAUTION: This has only been tested on
Mac OS X and CentOS.
Find UNIX pids based on app_name . CAUTION : This has only been tested on Mac OS X and CentOS .
def unix_pids
      pids = []
      x = `ps auxw | grep -v grep | awk '{print $2, $11}' | grep #{app_name}`
      if x && x.chomp!
        processes = x.split(/\n/).compact
        processes = processes.delete_if do |p|
          pid, name = p.split(/\s/)
          app_name != name[0..(app_name.length - 1)]
        end
        pids = processes.map {|p| p.split(/\s/)[0].to_i}
      end
      pids
    end
def unix_pids pids = [ ] x = ` ps auxw | grep -v grep | awk '{print $2, $11}' | grep  #{ app_name } ` if x && x . chomp! processes = x . split ( / \n / ) . compact processes = processes . delete_if do | p | pid , name = p . split ( / \s / ) app_name != name [ 0 .. ( app_name . length - 1 ) ] end pids = processes . map { | p | p . split ( / \s / ) [ 0 ] . to_i } end pids end
Find UNIX pids based on app_name.
Find UNIX pids based on app_name .
# We want to make sure that the first part of the process name matches # so that app_name matches app_name_22