module Raemon::Worker::InstanceMethods

Attributes

id[R]
logger[R]
master[R]
pid[RW]
pulse[R]

Public Class Methods

new(master, id, pulse) click to toggle source
# File lib/raemon/worker.rb, line 12
def initialize(master, id, pulse)
  @master = master
  @logger = master.logger
  @id     = id
  @pulse  = pulse
end

Public Instance Methods

==(other_id) click to toggle source
# File lib/raemon/worker.rb, line 19
def ==(other_id)
  @id == other_id
end
heartbeat!() click to toggle source
# File lib/raemon/worker.rb, line 43
def heartbeat!
  master.worker_heartbeat!(self)
end
memory_usage() click to toggle source
# File lib/raemon/worker.rb, line 37
def memory_usage
  usage = %xps -o rss= -p #{pid}`.to_i
  instrument 'worker.memory_usage', :pid => pid, :memory_used => usage
  return usage
end
run() click to toggle source
# File lib/raemon/worker.rb, line 33
def run
  raise NotImplementedError, "must be implemented in your class"
end
start() click to toggle source
# File lib/raemon/worker.rb, line 23
def start
  logger.info "=> Starting worker (PID: #{pid}, ID: #{id})"
  instrument 'worker.start', :pid => pid
end
stop() click to toggle source
# File lib/raemon/worker.rb, line 28
def stop
  logger.info "=> Stopping worker (PID: #{pid}, ID: #{id})"
  instrument 'worker.stop', :pid => pid
end