Class: Specinfra::Command::Alpine::Base::Process

Inherits:
Base
  • Object
show all
Defined in:
lib/specinfra/command/alpine/base/process.rb

Class Method Summary collapse

Methods inherited from Base

create, escape

Class Method Details

.check_count(process, count) ⇒ Object



16
17
18
# File 'lib/specinfra/command/alpine/base/process.rb', line 16

def check_count(process, count)
  "test $(ps -ocomm | grep -w -- #{escape(process)} | grep -v grep | wc -l) -eq #{escape(count)}"
end

.check_is_running(process) ⇒ Object



12
13
14
# File 'lib/specinfra/command/alpine/base/process.rb', line 12

def check_is_running(process)
  "ps -ocomm | grep -w -- #{escape(process)} | grep -qv grep"
end

.get(process, opts) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/specinfra/command/alpine/base/process.rb', line 3

def get(process, opts)
  col = opts[:format].chomp('=')
  if col == 'args'
    "ps -o #{col} | grep #{escape(process)} | head -1"
  else
    "ps -o #{col},args | grep -E '\\s+#{process}' | awk '{ print $1 }' | head -1"
  end
end