Module: Wmiirc::Loader

Defined in:
lib/wmiirc/loader.rb

Constant Summary

CONFIG_FILE =
File.join(DIR, 'config.yaml')
CONFIG_DUMP_FILE =
File.join(DIR,'config.dump')
CONFIG_SCHEMA_FILE =
File.join(DIR, 'schema.yaml')
CONFIG_SCHEMA =
YAML.load_file(CONFIG_SCHEMA_FILE)
CONFIG_VALIDATOR =
Kwalify::Validator.new(CONFIG_SCHEMA)
CONFIG_PARSER =
Kwalify::Yaml::Parser.new(CONFIG_VALIDATOR)

Class Method Summary (collapse)

Class Method Details

+ (Object) reload



43
44
45
46
47
48
49
50
51
# File 'lib/wmiirc/loader.rb', line 43

def reload
  LOG.info 'reload'
  #
  # NOTE: we launch another process here instead of exec()ing in order to
  # let this process terminate normally, thereby triggering at_exit hooks,
  # which in turn properly save the SESSION and do other necessary cleanup
  #
  Wmiirc.launch! File.expand_path($0), *ARGV
end

+ (Object) run



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/wmiirc/loader.rb', line 18

def run
  LOG.info 'start'

  log_standard_outputs
  terminate_other_instances
  load_user_config
  spawn 'witray' # relaunch to accomodate changes in screen resolution
  enter_event_loop

rescue SystemExit
  # ignore it; the program wants to terminate

rescue Errno::EPIPE => e
  LOG.error e
  LOG.info 'Lost connection to wmii.  Attempting to reconnect...'
  reload

rescue Exception => e
  LOG.error e
  allow_user_rescue e

ensure
  LOG.info 'stop'
end