Class: Fluentd::Agent::FluentdGem

Inherits:
Object
  • Object
show all
Includes:
Common
Defined in:
app/models/fluentd/agent/fluentd_gem.rb

Instance Attribute Summary

Attributes included from Common

#extra_options

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

#backup_files, #backup_files_in_new_order, #backup_files_in_old_order, #config, #config_append, #config_backup_dir, #config_file, #config_write, #configuration, included, #initialize, #log, #log_file, #pid_file, #running_config_backup_dir, #running_config_backup_file

Class Method Details

.default_optionsObject



6
7
8
9
10
11
12
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 6

def self.default_options
  {
    :pid_file    => "#{ENV["HOME"]}/.fluentd-ui/fluent.pid",
    :log_file    => "#{ENV["HOME"]}/.fluentd-ui/fluent.log",
    :config_file => "#{ENV["HOME"]}/.fluentd-ui/fluent.conf",
  }
end

Instance Method Details

#config_syntax_checkObject



48
49
50
51
52
53
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 48

def config_syntax_check
  Fluent::Config::V1Parser.parse(params[:config], config_file)
  true
rescue Fluent::ConfigParseError
  false
end

#dryrun!(file_path = nil) ⇒ Object



44
45
46
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 44

def dryrun!(file_path = nil)
  exec_dryrun("fluentd", file_path)
end

#reloadObject

NOTE: does not used currently, and td-agent has no reload command



39
40
41
42
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 39

def reload # NOTE: does not used currently, and td-agent has no reload command
  return false unless running?
  actual_reload
end

#restartObject

return value is status_after_this_method_called == started



30
31
32
33
34
35
36
37
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 30

def restart
  if running?
    validate_fluentd_options && stop && start
  else
    # NOTE: no path to here from browser operations for now
    start
  end
end

#startObject

return value is status_after_this_method_called == started



15
16
17
18
19
20
21
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 15

def start
  return true if running?

  backup_running_config do
    actual_start
  end
end

#stopObject

return value is status_after_this_method_called == stopped



24
25
26
27
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 24

def stop
  return true unless running?
  actual_stop
end

#versionObject



55
56
57
58
59
# File 'app/models/fluentd/agent/fluentd_gem.rb', line 55

def version
  Bundler.with_clean_env do
    `fluentd --version`.strip
  end
end