From cf88da111c2f8e45ad4bf3e953217a5e1f5a9511 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Sat, 24 Dec 2022 22:43:27 +0000 Subject: [PATCH 1/5] 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" From be452c48b0183c1143cb2ab0ead6348644603760 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 25 Dec 2022 00:18:17 +0100 Subject: [PATCH 2/5] improve layout of Sidekiq dashboard panel --- app/views/admin/dashboard/index.html.haml | 55 +++++++++++------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 26130d1f..6957a87b 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -1,31 +1,30 @@ -.card - .card-body - %h2 - Sidekiq +.row + .col-sm-6 + .card + .card-header + %a.d-flex{ href: sidekiq_web_path } + %strong Sidekiq + %i.fa.fa-chevron-right.ml-auto.align-self-center + - unless @sidekiq[:processes].count.positive? + .card-body.bg-danger.text-light + %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 - %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 + .list-group + .list-group-item.d-flex + %span Processes + %span.ml-auto= @sidekiq[:processes].count + .list-group-item.d-flex + %span Enqueued + %span.ml-auto= @sidekiq[:stats].enqueued + .list-group-item.d-flex + %span Retries + %span.ml-auto= @sidekiq[:stats].retry_size + .list-group-item.d-flex + %span Dead + %span.ml-auto= @sidekiq[:stats].dead_size - parent_layout "admin" From c730faa1b92295dc63538c7ec01bb01e600e991c Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 25 Dec 2022 00:19:08 +0100 Subject: [PATCH 3/5] Remove Sidekiq dashboard link from admin sidebar --- app/views/tabs/_admin.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/tabs/_admin.html.haml b/app/views/tabs/_admin.html.haml index 677a9cf0..3ce22fcb 100644 --- a/app/views/tabs/_admin.html.haml +++ b/app/views/tabs/_admin.html.haml @@ -6,5 +6,4 @@ .card .list-group = list_group_item t(".rails"), rails_admin_path - = list_group_item t(".sidekiq"), sidekiq_web_path = list_group_item t(".pghero"), pghero_path From 2e27c45bbef9a6707c8cbf67c998be1fb83d1eea Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 25 Dec 2022 00:23:53 +0100 Subject: [PATCH 4/5] move sidekiq panel into separate partial --- app/views/admin/dashboard/_sidekiq.html.haml | 26 +++++++++++++++++++ app/views/admin/dashboard/index.html.haml | 27 +------------------- 2 files changed, 27 insertions(+), 26 deletions(-) create mode 100644 app/views/admin/dashboard/_sidekiq.html.haml diff --git a/app/views/admin/dashboard/_sidekiq.html.haml b/app/views/admin/dashboard/_sidekiq.html.haml new file mode 100644 index 00000000..c937154d --- /dev/null +++ b/app/views/admin/dashboard/_sidekiq.html.haml @@ -0,0 +1,26 @@ +.card + .card-header + %a.d-flex{ href: sidekiq_web_path } + %strong Sidekiq + %i.fa.fa-chevron-right.ml-auto.align-self-center + - unless @sidekiq[:processes].count.positive? + .card-body.bg-danger.text-light + %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 + + .list-group + .list-group-item.d-flex + %span Processes + %span.ml-auto= @sidekiq[:processes].count + .list-group-item.d-flex + %span Enqueued + %span.ml-auto= @sidekiq[:stats].enqueued + .list-group-item.d-flex + %span Retries + %span.ml-auto= @sidekiq[:stats].retry_size + .list-group-item.d-flex + %span Dead + %span.ml-auto= @sidekiq[:stats].dead_size diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml index 6957a87b..a6422046 100644 --- a/app/views/admin/dashboard/index.html.haml +++ b/app/views/admin/dashboard/index.html.haml @@ -1,30 +1,5 @@ .row .col-sm-6 - .card - .card-header - %a.d-flex{ href: sidekiq_web_path } - %strong Sidekiq - %i.fa.fa-chevron-right.ml-auto.align-self-center - - unless @sidekiq[:processes].count.positive? - .card-body.bg-danger.text-light - %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 - - .list-group - .list-group-item.d-flex - %span Processes - %span.ml-auto= @sidekiq[:processes].count - .list-group-item.d-flex - %span Enqueued - %span.ml-auto= @sidekiq[:stats].enqueued - .list-group-item.d-flex - %span Retries - %span.ml-auto= @sidekiq[:stats].retry_size - .list-group-item.d-flex - %span Dead - %span.ml-auto= @sidekiq[:stats].dead_size + = render "admin/dashboard/sidekiq" - parent_layout "admin" From 7cc57968bc8f6596869b80f3dff531bd03528ebe Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 25 Dec 2022 00:29:24 +0100 Subject: [PATCH 5/5] Localize Sidekiq dashboard panel --- app/views/admin/dashboard/_sidekiq.html.haml | 16 ++++++---------- config/locales/views.en.yml | 13 +++++++++++++ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/views/admin/dashboard/_sidekiq.html.haml b/app/views/admin/dashboard/_sidekiq.html.haml index c937154d..6ce7fa7f 100644 --- a/app/views/admin/dashboard/_sidekiq.html.haml +++ b/app/views/admin/dashboard/_sidekiq.html.haml @@ -1,26 +1,22 @@ .card .card-header %a.d-flex{ href: sidekiq_web_path } - %strong Sidekiq + %strong= t(".title") %i.fa.fa-chevron-right.ml-auto.align-self-center - unless @sidekiq[:processes].count.positive? .card-body.bg-danger.text-light - %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 + = t(".error_html", env: Rails.env) .list-group .list-group-item.d-flex - %span Processes + %span= t(".processes") %span.ml-auto= @sidekiq[:processes].count .list-group-item.d-flex - %span Enqueued + %span= t(".enqueued") %span.ml-auto= @sidekiq[:stats].enqueued .list-group-item.d-flex - %span Retries + %span= t(".retries") %span.ml-auto= @sidekiq[:stats].retry_size .list-group-item.d-flex - %span Dead + %span= t(".dead") %span.ml-auto= @sidekiq[:stats].dead_size diff --git a/config/locales/views.en.yml b/config/locales/views.en.yml index f419a71a..02f0f2ad 100644 --- a/config/locales/views.en.yml +++ b/config/locales/views.en.yml @@ -88,6 +88,19 @@ en: title: "Create Announcement" edit: title: "Edit Announcement" + dashboard: + sidekiq: + title: "Sidekiq" + error_html: | + There are no Sidekiq processes running. + Background jobs will not be processed. +
+ To fix this, run + RAILS_ENV=%{env} bundle exec sidekiq + processes: "Processes" + enqueued: "Enqueued" + retries: "Retries" + dead: "Dead" answerbox: header: anon_hint: :inbox.entry.anon_hint