Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more OkComputer checks #393

Merged
merged 2 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ cache: bundler

rvm:
- 2.4.4

services:
- redis-server
39 changes: 39 additions & 0 deletions config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
# by default, okcomputer does "app up?" and "database conntected?" checks
OkComputer.mount_at = 'status' # use /status or /status/all or /status/<name-of-check>
OkComputer.check_in_parallel = true

OkComputer::Registry.register 'ruby_version', OkComputer::RubyVersionCheck.new

# check whether resque workers are working
OkComputer::Registry.register 'feature-resque-down', OkComputer::ResqueDownCheck.new

# check for backed up resque queues: this is a low volume app, so the threshold is low
Resque.queues.each do |queue|
OkComputer::Registry.register "feature-#{queue}-queue-depth", OkComputer::ResqueBackedUpCheck.new(queue, 5)
end

class DirectoryExistsCheck < OkComputer::Check
attr_accessor :directory

def initialize(directory)
self.directory = directory
end

def check
stat = File.stat(directory) if File.exist?(directory)
if stat
if stat.directory?
mark_message "'#{directory}' is a reachable directory"
else
mark_message "'#{directory}' is not a directory."
mark_failure
end
else
mark_message "Directory '#{directory}' does not exist."
mark_failure
end
end
end

# Confirm job_output_parent_dir exists (or else jobs cannot output)
OkComputer::Registry.register 'feature-job_output_parent_dir', DirectoryExistsCheck.new(Settings.job_output_parent_dir)

# To make checks optional:
# OkComputer.make_optional %w[feature-resque-down]