Class: Legion::CLI::Doctor::PidCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/cli/doctor/pid_check.rb

Constant Summary collapse

PID_PATHS =
['/var/run/legion.pid', '/tmp/legion.pid'].freeze

Instance Method Summary collapse

Instance Method Details

#fixObject



29
30
31
# File 'lib/legion/cli/doctor/pid_check.rb', line 29

def fix
  stale_pid_files.each { |f| File.delete(f) }
end

#nameObject



9
10
11
# File 'lib/legion/cli/doctor/pid_check.rb', line 9

def name
  'PID files'
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/legion/cli/doctor/pid_check.rb', line 13

def run
  stale = stale_pid_files
  if stale.empty?
    Result.new(name: name, status: :pass, message: 'No stale PID files')
  else
    rm_cmds = stale.map { |f| "rm #{f}" }.join('; ')
    Result.new(
      name:         name,
      status:       :warn,
      message:      "Stale PID file(s): #{stale.join(', ')}",
      prescription: "Remove with: #{rm_cmds}",
      auto_fixable: true
    )
  end
end