From cf88da111c2f8e45ad4bf3e953217a5e1f5a9511 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 24 Dec 2022 22:43:27 +0000 Subject: [PATCH] admin/dashboard: add basic sidekiq stats and warn if sidekiq is not running --- app/controllers/admin/dashboard_controller.rb | 9 +++++- app/views/admin/dashboard/index.html.haml | 28 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb index e1fcb69b..9d99570c 100644 --- a/app/controllers/admin/dashboard_controller.rb +++ b/app/controllers/admin/dashboard_controller.rb @@ -1,7 +1,14 @@ # frozen_string_literal: true +require "sidekiq/api" + class Admin::DashboardController < ApplicationController before_action :authenticate_user! - def index; end + def index + @sidekiq = { + processes: Sidekiq::ProcessSet.new, + stats: Sidekiq::Stats.new + } + end end diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index b2518836..26130d1f 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -1,5 +1,31 @@ .card .card-body - No dashboard content yet! + %h2 + Sidekiq + + %a{ href: sidekiq_web_path } View dashboard + + - unless @sidekiq[:processes].count.positive? + .alert.alert-danger{ role: :alert } + %strong There are no Sidekiq processes running. + Background jobs will not be processed. + %br + To fix this, run + %tt RAILS_ENV=#{Rails.env} bundle exec sidekiq + + %table.table + %tbody + %tr + %th Processes + %td= @sidekiq[:processes].count + %tr + %th Enqueued + %td= @sidekiq[:stats].enqueued + %tr + %th Retries + %td= @sidekiq[:stats].retry_size + %tr + %th Dead + %td= @sidekiq[:stats].dead_size - parent_layout "admin"