Monitor Ruby on Rails Jobs
Learn how to monitor Rails background jobs with Sidekiq, whenever gem, or ActiveJob.
Features
- Works with Sidekiq, Resque, and DelayedJob
- Whenever gem integration
- ActiveJob lifecycle callbacks
- Sidekiq Pro batch monitoring
Code Examples
Sidekiq Worker
class BackupWorker
include Sidekiq::Worker
def perform
check_url = "https://haspulse.io/ping/#{ENV['BACKUP_CHECK_ID']}"
# Signal start
Net::HTTP.get(URI("#{check_url}/start"))
begin
DatabaseBackup.run
Net::HTTP.get(URI(check_url))
rescue => e
Net::HTTP.get(URI("#{check_url}/fail"))
raise
end
end
end
# Schedule with sidekiq-cron:
# Sidekiq::Cron::Job.create(
# name: 'Backup - daily at 3am',
# cron: '0 3 * * *',
# class: 'BackupWorker'
# )whenever gem
# config/schedule.rb
set :output, '/var/log/cron.log'
every 1.day, at: '3:00 am' do
rake "db:backup",
before: "curl -fsS https://haspulse.io/ping/YOUR_CHECK_ID/start",
after: "curl -fsS https://haspulse.io/ping/YOUR_CHECK_ID"
end
every 5.minutes do
command "rake queue:process && curl -fsS https://haspulse.io/ping/QUEUE_CHECK_ID"
endHow It Works
- 1Create a check in HaspulseSet your expected schedule (e.g., every 5 minutes)
- 2Add the ping to your codePing the unique URL when your job runs successfully
- 3Get alerted on failuresIf a ping doesn't arrive on time, we notify you
Related Integrations
Start monitoring in minutes
Create your first check and start receiving alerts when your scheduled jobs fail.
Get started free