Class: Minus5::Daemon::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/minus5_daemon/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Runner

Returns a new instance of Runner.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/minus5_daemon/runner.rb', line 13

def initialize(klass)
  @klass = klass
  init_logger
  @config_file_set = false
  @options = Hashie::Mash.new(
    :daemonize => true,
    :config_file => 'config.yml',
    :environment => 'production',
    :app_name => start_script_name,
    :app_root => app_root)
  parse_arg_options
  load_config
  load_environment_file
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



28
29
30
# File 'lib/minus5_daemon/runner.rb', line 28

def logger
  @logger
end

Instance Method Details

#runObject



30
31
32
33
34
35
36
37
38
# File 'lib/minus5_daemon/runner.rb', line 30

def run
  mkdirs
  Daemons.run_proc(@options.app_name, daemon_options) do
    logger.info "starting daemon pid: #{Process.pid}"
    logger.debug "options: #{@options}"
    service = @klass.new(@options, @logger)
    service.run
  end
end