/usr/lib/ruby/vendor_ruby/raemon/worker.rb is in ruby-raemon 0.3.0+git.2012.05.18.b78eaae57c-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | module Raemon
module Worker
def self.included(base)
base.send :include, InstanceMethods
base.send :include, Instrumentation
end
module InstanceMethods
attr_reader :master, :logger, :id, :pulse
attr_accessor :pid
def initialize(master, id, pulse)
@master = master
@logger = master.logger
@id = id
@pulse = pulse
end
def ==(other_id)
@id == other_id
end
def start
logger.info "=> Starting worker (PID: #{pid}, ID: #{id})"
instrument 'worker.start', :pid => pid
end
def stop
logger.info "=> Stopping worker (PID: #{pid}, ID: #{id})"
instrument 'worker.stop', :pid => pid
end
def run
raise NotImplementedError, "must be implemented in your class"
end
def memory_usage
usage = `ps -o rss= -p #{pid}`.to_i
instrument 'worker.memory_usage', :pid => pid, :memory_used => usage
return usage
end
def heartbeat!
master.worker_heartbeat!(self)
end
end
end
end
|