Skip to content

Commit 9de31e0

Browse files
add back okcomputer (#510)
1 parent 2c5e3cc commit 9de31e0

4 files changed

Lines changed: 32 additions & 1 deletion

File tree

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ gem "jwt"
7575
# Pagination
7676
gem "kaminari"
7777

78+
# Server uptime monitoring
79+
gem "okcomputer"
80+
7881
group :development, :test do
7982
gem "debug", platforms: %i[ mri windows ], require: "debug/prelude"
8083
gem "bundler-audit", require: false

config/initializers/okcomputer.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
3+
# https://github.com/jphenow/okcomputer#registering-additional-checks
4+
#
5+
# class MyCustomCheck < OKComputer::Check
6+
# def call
7+
# if rand(10).even?
8+
# "Even is great!"
9+
# else
10+
# mark_failure
11+
# "We don't like odd numbers"
12+
# end
13+
# end
14+
# end
15+
16+
OkComputer::Registry.register "database", OkComputer::ActiveRecordCheck.new
17+
OkComputer::Registry.register "cache", OkComputer::CacheCheck.new
18+
19+
OkComputer::Registry.register "app_version", OkComputer::AppVersionCheck.new
20+
OkComputer::Registry.register "action_mailer", OkComputer::ActionMailerCheck.new
21+
22+
# Run checks in parallel
23+
OkComputer.check_in_parallel = true
24+
25+
# Log when health checks are run
26+
OkComputer.logger = Rails.logger

config/initializers/rack_attack.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Rack::Attack
1515
end
1616

1717
safelist("allow-healthchecks") do |req|
18-
req.path.start_with?("/up", "/healthchecks")
18+
req.path.start_with?("/up", "/healthchecks", "/okcomputer")
1919
end
2020

2121
# Admins and users with the bypass flag skip per-user API limits

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,7 @@
213213
mount LetterOpenerWeb::Engine, at: "/letter_opener"
214214
end
215215

216+
mount OkComputer::Engine, at: "/healthchecks"
217+
216218
root to: "home#index"
217219
end

0 commit comments

Comments
 (0)