File: process.rb

package info (click to toggle)
ruby-specinfra 2.89.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 2,412 kB
  • sloc: ruby: 10,338; sh: 4; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 618 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Specinfra::Command::Alpine::Base::Process < Specinfra::Command::Base
  class << self
    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

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

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