Depends on the sidekiq-cron gem.
curl https://gist.githubusercontent.com/ssaunier/e2d488bb931b5dc8df0f329c652eac25/raw/health_check_job.rb > app/jobs/health_check_job.rbYou need to set HEALTH_CHECK_URL in the prod ENV.
| class HealthCheckJob < ActiveJob::Base | |
| queue_as :default | |
| def perform | |
| require 'net/http' | |
| if ENV['HEALTH_CHECK_URL'].present? | |
| Net::HTTP.get(URI(ENV['HEALTH_CHECK_URL'])) | |
| else | |
| Rails.logger.warn("Cannot report good health. No HEALTH_CHECK_URL found in ENV.") | |
| end | |
| end | |
| end | |
| Sidekiq::Cron::Job.create( | |
| name: 'Notify healthchecks.io that a sidekiq worker is running', | |
| cron: '*/5 * * * *', | |
| klass: 'HealthCheckJob') |