Class: UnicornWrangler::RssReader

Inherits:
Object
  • Object
show all
Defined in:
lib/unicorn_wrangler/rss_reader.rb

Constant Summary collapse

LINUX =
RbConfig::CONFIG['host_os'].start_with?('linux')
PS_CMD =
'ps -o rss= -p %d'.freeze
VM_RSS =
/^VmRSS:\s+(\d+)\s+(\w+)/
UNITS =
{
  b:  1024**0,
  kb: 1024**1,
  mb: 1024**2,
  gb: 1024**3,
  tb: 1024**4,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(logger:) ⇒ RssReader

Returns a new instance of RssReader.



16
17
18
# File 'lib/unicorn_wrangler/rss_reader.rb', line 16

def initialize(logger:)
  @logger = logger
end

Instance Method Details

#rss(pid: Process.pid) ⇒ Object

Returns RSS in megabytes; should work on Linux and Mac OS X



21
22
23
# File 'lib/unicorn_wrangler/rss_reader.rb', line 21

def rss(pid: Process.pid)
  LINUX ? rss_linux(pid) : rss_posix(pid)
end