Class: Locd::CLI::Command::RotateLogs

Inherits:
Job show all
Defined in:
lib/locd/cli/command/rotate_logs.rb,
lib/locd/cli/command/rotate_logs/add.rb

Overview

Definitions

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Job

parse_every_option

Methods inherited from Agent

agent_type, #ls, #open, #rm, #status, #tail, #truncate_logs, #update

Class Method Details

.agent_classObject

Helpers



45
46
47
# File 'lib/locd/cli/command/rotate_logs.rb', line 45

def self.agent_class
  Locd::Agent::RotateLogs
end

Instance Method Details

#addObject



26
27
28
29
30
31
32
33
34
# File 'lib/locd/cli/command/rotate_logs/add.rb', line 26

def add
  agent = agent_class.add **option_kwds( groups: [ :write, :add ] )

  logger.info "#{ agent_class.name } `#{ agent.label }` created."
  
  agent.reload if options[:load]
  
  respond agent
end

#plistObject



99
100
101
102
103
104
105
# File 'lib/locd/cli/command/rotate_logs.rb', line 99

def plist
  if options[:json] || options[:yaml]
    respond agent.plist
  else
    respond agent.path.read
  end
end

#restartObject



135
136
137
# File 'lib/locd/cli/command/rotate_logs.rb', line 135

def restart
  agent.restart **option_kwds( :write, groups: :stop )
end

#run_Object



88
89
90
# File 'lib/locd/cli/command/rotate_logs.rb', line 88

def run_
  Locd::Newsyslog.run_all
end

#startObject



113
114
115
# File 'lib/locd/cli/command/rotate_logs.rb', line 113

def start
  agent.start **option_kwds( :write )
end

#stopObject



124
125
126
# File 'lib/locd/cli/command/rotate_logs.rb', line 124

def stop
  agent.stop **option_kwds( :unload, groups: :stop )
end