Class: SolidQueueGuard::Checks::Runtime::PidfileCheck

Inherits:
Base
  • Object
show all
Defined in:
lib/solid_queue_guard/checks/runtime/pidfile_check.rb

Instance Method Summary collapse

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/solid_queue_guard/checks/runtime/pidfile_check.rb', line 7

def call
  pidfile = ENV['SOLID_QUEUE_PIDFILE'] || default_pidfile
  return pass(check_id, 'No Solid Queue pidfile configured') if pidfile.blank?

  path = Pathname(pidfile)
  unless path.exist?
    return warn(check_id, "Pidfile not found at #{path}",
                suggestion: 'Verify Solid Queue supervisor is running')
  end

  pid = path.read.strip.to_i
  if process_alive?(pid)
    pass(check_id, "Solid Queue supervisor pidfile present (pid #{pid})")
  else
    failure(check_id, "Pidfile exists but process #{pid} is not running",
            suggestion: 'Restart the Solid Queue supervisor')
  end
end