Sha256: 60a113206d0d556f84e7abaa0a9c9d17e2eddcec2aeb5bbc90bd72bcc859e69c
Contents?: true
Size: 944 Bytes
Versions: 1
Compression:
Stored size: 944 Bytes
Contents
require 'net/http' require 'json' namespace :jobs do desc 'DJ のジョブが貯まっていたら slack で通知する' task notification: :environment do pending_jobs = Delayed::Job.where(:attempts => 0, :locked_at => nil).count if pending_jobs >= 50 alert = "[CRIT] ジョブが #{pending_jobs} 件残っています。ワーカーの状況を確認してください。" icon = ":critical:" elsif pending_jobs >= 20 alert = "[WARN] ジョブが #{pending_jobs} 件残っているようです。" icon = ":warning:" end if alert && icon uri = URI.parse(DelayedJobSlackNotification.webhook_url) params = { payload: { channel: DelayedJobSlackNotification.channel, username: DelayedJobSlackNotification.username, text: alert, icon_emoji: icon }.to_json } Net::HTTP.post_form(uri, params) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
delayed_job_slack_notification-0.1.3 | lib/tasks/delayed_job_slack_notification.rake |