Module: Eye::Process::Notify
- Included in:
- ChildProcess, Eye::Process
- Defined in:
- lib/eye/process/notify.rb
Constant Summary collapse
- LEVELS =
notify to user: 1) process crashed by itself, and we restart it [:info] 2) checker bounded to restart process [:warn] 3) flapping + switch to unmonitored [:error]
{:debug => 0, :info => 1, :warn => 2, :error => 3, :fatal => 4}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/eye/process/notify.rb', line 3 def self.included(base) base.class_eval do trap_exit :notify_died end end |
Instance Method Details
#notify(level, msg) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/eye/process/notify.rb', line 16 def notify(level, msg) # logging it error "NOTIFY: #{msg}" if ilevel(level) > ilevel(:info) # send notifies if self[:notify].present? = {:message => msg, :name => name, :full_name => full_name, :pid => pid, :host => Eye::Local.host, :level => level, :at => Time.now } self[:notify].each do |contact, not_level| Eye::Notify.notify(contact, ) if ilevel(level) >= ilevel(not_level) end end end |
#notify_died(actor, reason) ⇒ Object
32 33 34 |
# File 'lib/eye/process/notify.rb', line 32 def notify_died(actor, reason) error "NOTIFY DIED: #{actor.inspect} has died because of a #{reason.class}" end |