Class: Flydata::Command::Helper

Inherits:
Base
  • Object
show all
Defined in:
lib/flydata/command/helper.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  #daemon
  daemonize: false,
  supervisor: true,
  workers: 2,

  #logger
  log: nil,
  log_level: 'info',
  log_rotate_age: 10,
  log_rotate_size: 4294967295 # Set 4GB For disabling log rotation
  #log_rotate_size: 10*1024*1024
}

Instance Attribute Summary

Attributes inherited from Base

#opts

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ask_input_table_name, #ask_yes_no, #choose_one, #data_entry, #flydata, #newline, #register_crontab, #retrieve_data_entries, #separator, #show_purpose_name

Methods included from ExclusiveRunnable

included

Methods included from Flydata::CommandLoggable

#before_logging, #log_error_stderr, #log_info_stdout, #log_warn_stderr

Constructor Details

#initialize(options = Slop.new) ⇒ Helper

Returns a new instance of Helper.


36
37
38
39
40
# File 'lib/flydata/command/helper.rb', line 36

def initialize(options = Slop.new)
  super
  @helper_config = Flydata::Helper::ConfigParser.parse_file(opts[:config])[:helper]
  create_helper_dirs
end

Class Method Details

.slop_startObject


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/flydata/command/helper.rb', line 24

def self.slop_start
  Slop.new do
    on 'c=', 'config=','config file path'
    on 'n', 'no-daemon', 'Start Helper as a regular program'
    on 'l=', 'log=', 'log file path'
    on 'e=', 'level=', 'log level'
    on 'r=', 'rotate=', 'Number of times logs are rotated before being removed'
    on 's=', 'size=', 'Size (in bytes) after which log is rotated'
    #For now, size needs to be specified in bytes (dont think it will be used often)
  end
end

Instance Method Details

#restartObject


66
67
68
69
70
71
72
73
# File 'lib/flydata/command/helper.rb', line 66

def restart
  if running?
    log_info_stdout("Restarting Helper.")
    run_command(kill_hup_cmd)
  else
    raw_start
  end
end

#startObject


42
43
44
45
46
47
48
# File 'lib/flydata/command/helper.rb', line 42

def start
  if running?
    log_info_stdout("Helper is already running.")
  else
    raw_start
  end
end

#statusObject


58
59
60
61
62
63
64
# File 'lib/flydata/command/helper.rb', line 58

def status
  if running?
    log_info_stdout("Helper is running.")
  else
    log_info_stdout("Helper is not running.")
  end
end

#stopObject


50
51
52
53
54
55
56
# File 'lib/flydata/command/helper.rb', line 50

def stop
  if running?
    run_command(stop_cmd)
  else
    log_info_stdout("Helper is not running.")
  end
end