module Eye::Process::Config

Constants

DEFAULTS

Public Instance Methods

[](name) click to toggle source
# File lib/eye/process/config.rb, line 51
def [](name)
  @config[name]
end
c(name) click to toggle source
# File lib/eye/process/config.rb, line 47
def c(name)
  @config[name]
end
control_pid?() click to toggle source

is pid_file under Eye::Process control, or not

# File lib/eye/process/config.rb, line 77
def control_pid?
  !!self[:daemonize]
end
prepare_config(new_config) click to toggle source
# File lib/eye/process/config.rb, line 25
def prepare_config(new_config)
  h = DEFAULTS.merge(new_config)
  h[:pid_file_ex] = Eye::System.normalized_file(h[:pid_file], h[:working_dir]) if h[:pid_file]
  h[:checks] = {} if h[:checks].blank?
  h[:triggers] = {} if h[:triggers].blank?
  h[:children_update_period] = h[:monitor_children][:children_update_period] if h[:monitor_children] && h[:monitor_children][:children_update_period]

  # check speedy flapping by default
  if h[:triggers].blank? || !h[:triggers][:flapping]
    h[:triggers] ||= {}
    h[:triggers][:flapping] = {:type => :flapping, :times => 10, :within => 10.seconds}
  end

  h[:stdout] = Eye::System.normalized_file(h[:stdout], h[:working_dir]) if h[:stdout]
  h[:stderr] = Eye::System.normalized_file(h[:stderr], h[:working_dir]) if h[:stderr]
  h[:stdall] = Eye::System.normalized_file(h[:stdall], h[:working_dir]) if h[:stdall]

  h[:environment] = Eye::System.prepare_env(h)

  h
end
update_config(new_config = {}) click to toggle source
# File lib/eye/process/config.rb, line 55
def update_config(new_config = {})
  new_config = prepare_config(new_config)
  @config = new_config
  @full_name = nil
  @logger = nil

  debug "updating config to: #{@config.inspect}"

  remove_triggers
  add_triggers

  if up?
    # rebuild checks for this process
    remove_watchers
    remove_children

    add_watchers
    add_children
  end
end