Class: TriggerSwitchD::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/trigger_switch_d/application.rb

Overview

starts an instance of the daemon.

Constant Summary collapse

ANYTHING_STR =
"anything"
RESPONSE_STR =
"response"
RECEIVED_STR =
"received"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_file) ⇒ Application

Prepares the run by loading up the environment located in config/config.rb



32
33
34
35
36
37
# File 'lib/trigger_switch_d/application.rb', line 32

def initialize(config_file)
  @current_date = Date.new
  ConfigFactory.new(config_file)
  @logger = Logger.new(Config.log_object)
  logger.info("Environment prepared")
end

Instance Attribute Details

#devicesObject (readonly) Also known as: list_devices

Returns the value of attribute devices.



27
28
29
# File 'lib/trigger_switch_d/application.rb', line 27

def devices
  @devices
end

#loggerObject (readonly)

Returns the value of attribute logger.



27
28
29
# File 'lib/trigger_switch_d/application.rb', line 27

def logger
  @logger
end

#scheduleObject (readonly)

Returns the value of attribute schedule.



27
28
29
# File 'lib/trigger_switch_d/application.rb', line 27

def schedule
  @schedule
end

Instance Method Details

#list_scheduleObject

:nodoc:



51
52
53
# File 'lib/trigger_switch_d/application.rb', line 51

def list_schedule #:nodoc:
  schedule.by_name.keys
end

#startObject

Runs the daemon untill process killed or it receives stop from client connected via unix socket



44
45
46
47
48
49
# File 'lib/trigger_switch_d/application.rb', line 44

def start
  @ipc = IPC.create(Config.unix_socket_path)
  @logger.info("IPC started")
  __run_loop__
  @logger.info("Received stop via IPC")
end