Rails · Sidekiq

Monitor Sidekiq Scheduled Jobs

Sidekiq has no built-in cron scheduling — most Rails apps pair it with sidekiq-cron or sidekiq-scheduler for recurring jobs. Either way, the failure modes are the same as any background worker: the Sidekiq process dies, Redis connectivity drops, or a job silently raises and never completes.

Setup

1

Create an incoming monitor

Add a heartbeat monitor in Pingtastic for the job, with a grace period a little past its schedule interval.

2

Ping at the end of the worker's perform method

After the job's work completes successfully, send a request to the ping URL.

app/workers/nightly_report_worker.rb
class NightlyReportWorker
  include Sidekiq::Worker

  def perform
    # ...existing job logic...

    Net::HTTP.get(URI('https://ping.pingtastic.net/ping/nightly-report'))
  end
end

Gotchas

  • ⚠If the Sidekiq process itself is down (crashed, not restarted after a deploy), scheduled jobs queued by sidekiq-cron/sidekiq-scheduler just pile up unprocessed — no job runs, so no ping fires, which correctly triggers an alert.
  • ⚠A job that raises partway through never reaches the ping call — that's the desired behavior, but make sure the ping is placed after the actual work, not at the top of perform, or failures will be masked.

Questions

Do I need sidekiq-cron or sidekiq-scheduler for this to work?

You need one of them (or an equivalent) to get recurring scheduling in Sidekiq at all — Pingtastic monitoring is independent of which scheduling gem you use; it just cares that the worker's perform method reaches the ping call.

What if Redis itself is down?

With Redis unreachable, Sidekiq can't dequeue or schedule jobs at all, so the job never runs and never pings — exactly the failure case the heartbeat is meant to catch.

Start monitoring your Rails sidekiq

Set up your first monitor in under five minutes.

Get started — $5/month