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, #dashboard_url, #data_entry, #data_port, #flydata, #newline, #redshift_cluster, #redshift_console_url, #register_crontab, #retrieve_data_entries, #separator, #show_purpose_name, #source

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

#reload(options = {}) ⇒ Object



76
77
78
79
80
81
# File 'lib/flydata/command/helper.rb', line 76

def reload(options = {})
  if running?
    log_info_stdout("Reloading Helper.", {}, options)
    run_command(kill_hup_cmd, options)
  end
end

#restart(options = {}) ⇒ Object



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

def restart(options = {})
  if running?
    log_info_stdout("Restarting Helper.", {}, options)
    unless run_command(stop_cmd, options)
      raise "[error] Failed to stop helper process. Please run 'flydata helper:restart' after checking the process."
    end
  end
  start(options)
end

#start(options = {}) ⇒ Object



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

def start(options = {})
  if running?
    log_info_stdout("Helper is already running.", {}, options)
  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

#stop(options = {}) ⇒ Object



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

def stop(options = {})
  if running?
    run_command(stop_cmd, options)
  else
    log_info_stdout("Helper is not running.", {}, options)
  end
end