sidekiq 8.1.1 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes.md +27 -2
- data/README.md +1 -1
- data/bin/kiq +17 -0
- data/lib/active_job/queue_adapters/sidekiq_adapter.rb +8 -8
- data/lib/sidekiq/api.rb +46 -35
- data/lib/sidekiq/capsule.rb +0 -1
- data/lib/sidekiq/cli.rb +1 -1
- data/lib/sidekiq/client.rb +3 -1
- data/lib/sidekiq/component.rb +3 -0
- data/lib/sidekiq/config.rb +1 -1
- data/lib/sidekiq/launcher.rb +1 -1
- data/lib/sidekiq/manager.rb +1 -1
- data/lib/sidekiq/paginator.rb +6 -1
- data/lib/sidekiq/profiler.rb +1 -1
- data/lib/sidekiq/scheduled.rb +2 -5
- data/lib/sidekiq/tui/controls.rb +53 -0
- data/lib/sidekiq/tui/filtering.rb +53 -0
- data/lib/sidekiq/tui/tabs/base_tab.rb +187 -0
- data/lib/sidekiq/tui/tabs/busy.rb +118 -0
- data/lib/sidekiq/tui/tabs/dead.rb +19 -0
- data/lib/sidekiq/tui/tabs/home.rb +144 -0
- data/lib/sidekiq/tui/tabs/metrics.rb +131 -0
- data/lib/sidekiq/tui/tabs/queues.rb +95 -0
- data/lib/sidekiq/tui/tabs/retries.rb +19 -0
- data/lib/sidekiq/tui/tabs/scheduled.rb +19 -0
- data/lib/sidekiq/tui/tabs/set_tab.rb +96 -0
- data/lib/sidekiq/tui/tabs.rb +15 -0
- data/lib/sidekiq/tui.rb +274 -913
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/web/helpers.rb +32 -3
- data/lib/sidekiq.rb +1 -1
- data/sidekiq.gemspec +1 -1
- data/web/assets/stylesheets/style.css +2 -0
- data/web/locales/ar.yml +1 -1
- data/web/locales/fa.yml +1 -1
- data/web/locales/gd.yml +1 -1
- data/web/locales/he.yml +1 -1
- data/web/locales/pt-BR.yml +1 -1
- data/web/locales/ur.yml +1 -1
- data/web/locales/zh-TW.yml +1 -1
- data/web/views/_paging.html.erb +1 -1
- metadata +15 -2
- data/bin/tui +0 -5
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
|
|
3
|
+
module Sidekiq
|
|
4
|
+
class TUI
|
|
5
|
+
module Tabs
|
|
6
|
+
class Busy < BaseTab
|
|
7
|
+
def features
|
|
8
|
+
%i[selectable]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def controls
|
|
12
|
+
@controls ||= super + [
|
|
13
|
+
{code: "T", modifiers: ["shift"], description: "Terminate", action: ->(tui, tab) { tab.terminate! }},
|
|
14
|
+
{code: "Q", modifiers: ["shift"], description: "Quiet", action: ->(tui, tab) { tab.quiet! }}
|
|
15
|
+
]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def quiet!
|
|
19
|
+
each_selection do |id|
|
|
20
|
+
Sidekiq::Process.new("identity" => id).quiet!
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def terminate!
|
|
25
|
+
each_selection do |id|
|
|
26
|
+
Sidekiq::Process.new("identity" => id).stop!
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def refresh_data
|
|
31
|
+
refresh_data_for_stats
|
|
32
|
+
|
|
33
|
+
busy = []
|
|
34
|
+
table_row_ids = []
|
|
35
|
+
|
|
36
|
+
Sidekiq::ProcessSet.new.each do |p|
|
|
37
|
+
name = "#{p["hostname"]}:#{p["pid"]}"
|
|
38
|
+
name += " ⭐️" if p.leader?
|
|
39
|
+
name += " 🛑" if p.stopping?
|
|
40
|
+
busy << [
|
|
41
|
+
selected?(p) ? "✅" : "",
|
|
42
|
+
name,
|
|
43
|
+
Time.at(p["started_at"]).utc,
|
|
44
|
+
format_memory(p["rss"].to_i),
|
|
45
|
+
number_with_delimiter(p["concurrency"]),
|
|
46
|
+
number_with_delimiter(p["busy"])
|
|
47
|
+
]
|
|
48
|
+
table_row_ids << p.identity
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
@data[:busy] = busy
|
|
52
|
+
@data[:table] = {row_ids: table_row_ids}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def render(tui, frame, area)
|
|
56
|
+
chunks = tui.layout_split(
|
|
57
|
+
area,
|
|
58
|
+
direction: :vertical,
|
|
59
|
+
constraints: [
|
|
60
|
+
tui.constraint_length(4), # Stats
|
|
61
|
+
tui.constraint_length(4), # Status
|
|
62
|
+
tui.constraint_fill(1) # Graph
|
|
63
|
+
]
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
render_stats_section(tui, frame, chunks[0])
|
|
67
|
+
render_status_section(tui, frame, chunks[1])
|
|
68
|
+
render_table(tui, frame, chunks[2]) do
|
|
69
|
+
{
|
|
70
|
+
title: t("Processes"),
|
|
71
|
+
header: ["☑️", "Name", "Started", "RSS", "Threads", "Busy"].map { |x| t(x) },
|
|
72
|
+
widths: [
|
|
73
|
+
tui.constraint_length(5),
|
|
74
|
+
tui.constraint_fill(1),
|
|
75
|
+
tui.constraint_length(24),
|
|
76
|
+
tui.constraint_length(10),
|
|
77
|
+
tui.constraint_length(6),
|
|
78
|
+
tui.constraint_length(6)
|
|
79
|
+
],
|
|
80
|
+
rows: @data[:busy].map.with_index { |cells, idx|
|
|
81
|
+
tui.table_row(
|
|
82
|
+
cells:,
|
|
83
|
+
style: idx.even? ? nil : tui.style(bg: :dark_gray)
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def render_status_section(tui, frame, area)
|
|
91
|
+
values = []
|
|
92
|
+
processes = Sidekiq::ProcessSet.new
|
|
93
|
+
workset = Sidekiq::WorkSet.new
|
|
94
|
+
ws = workset.size
|
|
95
|
+
values << (s = processes.size
|
|
96
|
+
number_with_delimiter(s))
|
|
97
|
+
values << (x = processes.total_concurrency
|
|
98
|
+
number_with_delimiter(x))
|
|
99
|
+
values << number_with_delimiter(ws)
|
|
100
|
+
values << "#{(x == 0) ? 0 : ((ws / x.to_f) * 100).round(0)}%"
|
|
101
|
+
values << format_memory(processes.total_rss)
|
|
102
|
+
|
|
103
|
+
keys = %w[Processes Threads Busy Utilization RSS]
|
|
104
|
+
keys_line = keys.map { |k| t(k).to_s.ljust(12) }.join(" ")
|
|
105
|
+
values_line = values.map { |v| v.to_s.ljust(12) }.join(" ")
|
|
106
|
+
|
|
107
|
+
frame.render_widget(
|
|
108
|
+
tui.paragraph(
|
|
109
|
+
text: [keys_line, values_line],
|
|
110
|
+
block: tui.block(title: t("Status"), borders: [:all])
|
|
111
|
+
),
|
|
112
|
+
area
|
|
113
|
+
)
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
require_relative "set_tab"
|
|
3
|
+
|
|
4
|
+
module Sidekiq
|
|
5
|
+
class TUI
|
|
6
|
+
module Tabs
|
|
7
|
+
class Dead < BaseTab
|
|
8
|
+
include SetTab
|
|
9
|
+
|
|
10
|
+
def set_class = Sidekiq::DeadSet
|
|
11
|
+
|
|
12
|
+
def refresh_data
|
|
13
|
+
refresh_data_for_stats
|
|
14
|
+
refresh_data_for_set
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
|
|
3
|
+
module Sidekiq
|
|
4
|
+
class TUI
|
|
5
|
+
module Tabs
|
|
6
|
+
class Home < BaseTab
|
|
7
|
+
def refresh_data
|
|
8
|
+
refresh_data_for_stats
|
|
9
|
+
|
|
10
|
+
stats = Sidekiq::Stats.new
|
|
11
|
+
@data[:chart] ||= {
|
|
12
|
+
previous_stats: {
|
|
13
|
+
processed: stats.processed,
|
|
14
|
+
failed: stats.failed
|
|
15
|
+
},
|
|
16
|
+
deltas: {
|
|
17
|
+
processed: Array.new(50, 0),
|
|
18
|
+
failed: Array.new(50, 0)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
processed_delta = stats.processed - @data[:chart][:previous_stats][:processed]
|
|
23
|
+
failed_delta = stats.failed - @data[:chart][:previous_stats][:failed]
|
|
24
|
+
|
|
25
|
+
@data[:chart][:deltas][:processed].shift
|
|
26
|
+
@data[:chart][:deltas][:processed].push(processed_delta)
|
|
27
|
+
@data[:chart][:deltas][:failed].shift
|
|
28
|
+
@data[:chart][:deltas][:failed].push(failed_delta)
|
|
29
|
+
|
|
30
|
+
@data[:chart][:previous_stats] = {
|
|
31
|
+
processed: stats.processed,
|
|
32
|
+
failed: stats.failed
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
redis_info = Sidekiq.default_configuration.redis_info
|
|
36
|
+
|
|
37
|
+
@data[:redis_info] = {
|
|
38
|
+
version: redis_info["redis_version"] || "N/A",
|
|
39
|
+
uptime_days: redis_info["uptime_in_days"] || "N/A",
|
|
40
|
+
connected_clients: redis_info["connected_clients"] || "N/A",
|
|
41
|
+
used_memory: redis_info["used_memory_human"] || "N/A",
|
|
42
|
+
peak_memory: redis_info["used_memory_peak_human"] || "N/A"
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def render(tui, frame, area)
|
|
47
|
+
chunks = tui.layout_split(
|
|
48
|
+
area,
|
|
49
|
+
direction: :vertical,
|
|
50
|
+
constraints: [
|
|
51
|
+
tui.constraint_length(4), # Stats
|
|
52
|
+
tui.constraint_fill(1), # Graph
|
|
53
|
+
tui.constraint_length(4) # Redis
|
|
54
|
+
]
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
render_stats_section(tui, frame, chunks[0])
|
|
58
|
+
render_chart_section(tui, frame, chunks[1])
|
|
59
|
+
render_redis_info_section(tui, frame, chunks[2])
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def render_chart_section(tui, frame, area)
|
|
63
|
+
max_value = [@data[:chart][:deltas][:processed].max, @data[:chart][:deltas][:failed].max, 1].max
|
|
64
|
+
y_max = [max_value, 5].max
|
|
65
|
+
|
|
66
|
+
processed_data = @data[:chart][:deltas][:processed].each_with_index.map { |value, idx| [idx.to_f, value.to_f] }
|
|
67
|
+
failed_data = @data[:chart][:deltas][:failed].each_with_index.map { |value, idx| [idx.to_f, value.to_f] }
|
|
68
|
+
|
|
69
|
+
datasets = [
|
|
70
|
+
tui.dataset(
|
|
71
|
+
name: "",
|
|
72
|
+
data: processed_data,
|
|
73
|
+
style: tui.style(fg: :green),
|
|
74
|
+
marker: :dot,
|
|
75
|
+
graph_type: :line
|
|
76
|
+
),
|
|
77
|
+
tui.dataset(
|
|
78
|
+
name: "",
|
|
79
|
+
data: failed_data,
|
|
80
|
+
style: tui.style(fg: :red),
|
|
81
|
+
marker: :dot,
|
|
82
|
+
graph_type: :line
|
|
83
|
+
)
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
num_labels = 5
|
|
87
|
+
y_labels = (0...num_labels).map do |i|
|
|
88
|
+
value = ((y_max * i) / (num_labels - 1)).round
|
|
89
|
+
value.to_s
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
beacon_pulse = (Time.now.to_i % 2 == 0) ? "●" : " "
|
|
93
|
+
|
|
94
|
+
chart = tui.chart(
|
|
95
|
+
datasets: datasets,
|
|
96
|
+
x_axis: tui.axis(
|
|
97
|
+
bounds: [0.0, 49.0],
|
|
98
|
+
labels: [],
|
|
99
|
+
style: tui.style(fg: :white)
|
|
100
|
+
),
|
|
101
|
+
y_axis: tui.axis(
|
|
102
|
+
bounds: [0.0, y_max.to_f],
|
|
103
|
+
labels: y_labels,
|
|
104
|
+
style: tui.style(fg: :white)
|
|
105
|
+
),
|
|
106
|
+
block: tui.block(
|
|
107
|
+
title: "Dashboard #{beacon_pulse}",
|
|
108
|
+
borders: [:all]
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
frame.render_widget(chart, area)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def render_redis_info_section(tui, frame, area)
|
|
116
|
+
redis_info = @data[:redis_info]
|
|
117
|
+
|
|
118
|
+
uptime_value = (redis_info[:uptime_days] == "N/A") ? "N/A" : "#{redis_info[:uptime_days]} days"
|
|
119
|
+
|
|
120
|
+
keys = ["Version", "Uptime", "Connected Clients", "Memory Usage", "Peak Memory"]
|
|
121
|
+
values = [
|
|
122
|
+
redis_info[:version].to_s,
|
|
123
|
+
uptime_value,
|
|
124
|
+
redis_info[:connected_clients].to_s,
|
|
125
|
+
redis_info[:used_memory].to_s,
|
|
126
|
+
redis_info[:peak_memory].to_s
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
# Format keys and values with spacing
|
|
130
|
+
keys_line = keys.map { |k| t(k).ljust(18) }.join(" ")
|
|
131
|
+
values_line = values.map { |v| v.ljust(18) }.join(" ")
|
|
132
|
+
|
|
133
|
+
frame.render_widget(
|
|
134
|
+
tui.paragraph(
|
|
135
|
+
text: [keys_line, values_line],
|
|
136
|
+
block: tui.block(title: "Redis Information", borders: [:all])
|
|
137
|
+
),
|
|
138
|
+
area
|
|
139
|
+
)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
|
|
3
|
+
module Sidekiq
|
|
4
|
+
class TUI
|
|
5
|
+
module Tabs
|
|
6
|
+
class Metrics < BaseTab
|
|
7
|
+
include Filtering
|
|
8
|
+
|
|
9
|
+
COLORS = %i[light_blue light_cyan light_yellow light_red light_green white gray]
|
|
10
|
+
|
|
11
|
+
def features
|
|
12
|
+
%i[filterable]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def on_filter_change
|
|
16
|
+
@data[:metrics_refresh] = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def regexp
|
|
20
|
+
filtering? ? Regexp.new(Regexp.escape(current_filter), Regexp::IGNORECASE) : nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def refresh_data
|
|
24
|
+
refresh_data_for_stats
|
|
25
|
+
|
|
26
|
+
# only need to refresh every 60 seconds
|
|
27
|
+
if !@data[:metrics_refresh] || @data[:metrics_refresh] < Time.now
|
|
28
|
+
q = Sidekiq::Metrics::Query.new
|
|
29
|
+
query_result = q.top_jobs(class_filter: regexp, minutes: 60)
|
|
30
|
+
@data[:metrics] = query_result
|
|
31
|
+
@data[:metrics_refresh] = Time.now + 60
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def render(tui, frame, area)
|
|
36
|
+
chunks = tui.layout_split(
|
|
37
|
+
area,
|
|
38
|
+
direction: :vertical,
|
|
39
|
+
constraints: [
|
|
40
|
+
tui.constraint_length(4), # Stats
|
|
41
|
+
tui.constraint_fill(1) # Chart
|
|
42
|
+
# TOOD Table
|
|
43
|
+
]
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
render_stats_section(tui, frame, chunks[0])
|
|
47
|
+
render_metrics_chart(tui, frame, chunks[1])
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# Run to generate metrics data:
|
|
51
|
+
# cd myapp && bundle install
|
|
52
|
+
# bundle exec rake seed_jobs
|
|
53
|
+
# bundle exec sidekiq
|
|
54
|
+
def render_metrics_chart(tui, frame, area)
|
|
55
|
+
y_max = 5
|
|
56
|
+
csize = COLORS.size
|
|
57
|
+
q = @data[:metrics]
|
|
58
|
+
job_results = q.job_results.sort_by { |(kls, jr)| jr.totals["s"] }.reverse.first(COLORS.size)
|
|
59
|
+
# visible_kls = job_results.first(5).map(&:first)
|
|
60
|
+
# chart_data = {
|
|
61
|
+
# series: job_results.map { |(kls, jr)| [kls, jr.dig("series", "s")] }.to_h,
|
|
62
|
+
# marks: query_result.marks.map { |m| [m.bucket, m.label] },
|
|
63
|
+
# starts_at: query_result.starts_at.iso8601,
|
|
64
|
+
# ends_at: query_result.ends_at.iso8601,
|
|
65
|
+
# visibleKls: visible_kls,
|
|
66
|
+
# yLabel: 'TotalExecutionTime',
|
|
67
|
+
# units: 'seconds',
|
|
68
|
+
# markLabel: '*',
|
|
69
|
+
# }
|
|
70
|
+
|
|
71
|
+
datasets = job_results.map.with_index do |(kls, data), idx|
|
|
72
|
+
# log kls, data, idx
|
|
73
|
+
hrdata = data.dig("series", "s")
|
|
74
|
+
tm = Time.now
|
|
75
|
+
tmi = tm.to_i
|
|
76
|
+
tm = Time.at(tmi - (tmi % 60)).utc
|
|
77
|
+
data = Array.new(60) { |idx| idx }.map do |bucket_idx|
|
|
78
|
+
jumpback = bucket_idx * 60
|
|
79
|
+
value = hrdata[(tm - jumpback).iso8601] || 0
|
|
80
|
+
y_max = value if value > y_max
|
|
81
|
+
# we have 60 data points, newest data should be
|
|
82
|
+
# at highest indexes so we have to rejigger the index
|
|
83
|
+
# here
|
|
84
|
+
[59 - bucket_idx, value]
|
|
85
|
+
end
|
|
86
|
+
# log data
|
|
87
|
+
|
|
88
|
+
# log(data)
|
|
89
|
+
tui.dataset(name: kls,
|
|
90
|
+
data: data,
|
|
91
|
+
style: tui.style(fg: COLORS[idx % csize]),
|
|
92
|
+
marker: :dot,
|
|
93
|
+
graph_type: :line)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
num_labels = 5
|
|
97
|
+
y_labels = (0...num_labels).map do |i|
|
|
98
|
+
value = ((y_max * i) / (num_labels - 1)).round
|
|
99
|
+
value.to_s
|
|
100
|
+
end
|
|
101
|
+
xlabels = [
|
|
102
|
+
q.starts_at.iso8601[11..15],
|
|
103
|
+
q.ends_at.iso8601[11..15]
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
# beacon_pulse = (Time.now.to_i % 2 == 0) ? "●" : " "
|
|
107
|
+
|
|
108
|
+
chart = tui.chart(
|
|
109
|
+
datasets: datasets,
|
|
110
|
+
x_axis: tui.axis(
|
|
111
|
+
bounds: [0.0, 60.0],
|
|
112
|
+
labels: xlabels,
|
|
113
|
+
style: tui.style(fg: :white)
|
|
114
|
+
),
|
|
115
|
+
y_axis: tui.axis(
|
|
116
|
+
bounds: [0.0, y_max.to_f],
|
|
117
|
+
labels: y_labels,
|
|
118
|
+
style: tui.style(fg: :white)
|
|
119
|
+
),
|
|
120
|
+
block: tui.block(
|
|
121
|
+
title: t(name),
|
|
122
|
+
borders: [:all]
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
frame.render_widget(chart, area)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
|
|
3
|
+
module Sidekiq
|
|
4
|
+
class TUI
|
|
5
|
+
module Tabs
|
|
6
|
+
class Queues < BaseTab
|
|
7
|
+
def features
|
|
8
|
+
%i[selectable]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def controls
|
|
12
|
+
@controls ||= super + [
|
|
13
|
+
{code: "D", modifiers: ["shift"], display: "D", description: "Delete",
|
|
14
|
+
action: ->(tui, tab) { tab.delete_queue! }, refresh: true},
|
|
15
|
+
{code: "p", description: "Pause/Unpause Queue",
|
|
16
|
+
action: ->(tui, tab) { tab.toggle_pause_queue! }}
|
|
17
|
+
]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def delete_queue!
|
|
21
|
+
each_selection do |qname|
|
|
22
|
+
Sidekiq::Queue.new(qname).clear
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def toggle_pause_queue!
|
|
27
|
+
return unless Sidekiq.pro?
|
|
28
|
+
|
|
29
|
+
each_selection do |qname|
|
|
30
|
+
queue = Sidekiq::Queue.new(qname)
|
|
31
|
+
if queue.paused?
|
|
32
|
+
queue.unpause!
|
|
33
|
+
else
|
|
34
|
+
queue.pause!
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def refresh_data
|
|
40
|
+
refresh_data_for_stats
|
|
41
|
+
|
|
42
|
+
queue_summaries = Sidekiq::Stats.new.queue_summaries.sort_by(&:name)
|
|
43
|
+
|
|
44
|
+
selected = Array(@data[:selected])
|
|
45
|
+
queues = queue_summaries.map { |queue_summary|
|
|
46
|
+
row_cells = [
|
|
47
|
+
selected.index(queue_summary.name) ? "✅" : "",
|
|
48
|
+
queue_summary.name,
|
|
49
|
+
queue_summary.size.to_s,
|
|
50
|
+
number_with_delimiter(queue_summary.latency, {precision: 2})
|
|
51
|
+
]
|
|
52
|
+
row_cells << (queue_summary.paused? ? "✅" : "") if Sidekiq.pro?
|
|
53
|
+
row_cells
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
table_row_ids = queue_summaries.map(&:name)
|
|
57
|
+
|
|
58
|
+
@data[:queues] = queues
|
|
59
|
+
@data[:table] = {row_ids: table_row_ids}
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def render(tui, frame, area)
|
|
63
|
+
header = ["☑️", "Queue", "Size", "Latency"].map { |x| t(x) }
|
|
64
|
+
header << "Paused?" if Sidekiq.pro?
|
|
65
|
+
|
|
66
|
+
chunks = tui.layout_split(
|
|
67
|
+
area,
|
|
68
|
+
direction: :vertical,
|
|
69
|
+
constraints: [
|
|
70
|
+
tui.constraint_length(4), # Stats
|
|
71
|
+
tui.constraint_fill(1) # Table
|
|
72
|
+
]
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
render_stats_section(tui, frame, chunks[0])
|
|
76
|
+
render_table(tui, frame, chunks[1]) do
|
|
77
|
+
{
|
|
78
|
+
title: t(name),
|
|
79
|
+
header:,
|
|
80
|
+
widths: header.map.with_index { |_, idx|
|
|
81
|
+
tui.constraint_length((idx == 1) ? 60 : 10)
|
|
82
|
+
},
|
|
83
|
+
rows: @data[:queues].map.with_index { |cells, idx|
|
|
84
|
+
tui.table_row(
|
|
85
|
+
cells:,
|
|
86
|
+
style: idx.even? ? nil : tui.style(bg: :dark_gray)
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
require_relative "set_tab"
|
|
3
|
+
|
|
4
|
+
module Sidekiq
|
|
5
|
+
class TUI
|
|
6
|
+
module Tabs
|
|
7
|
+
class Retries < BaseTab
|
|
8
|
+
include SetTab
|
|
9
|
+
|
|
10
|
+
def set_class = Sidekiq::RetrySet
|
|
11
|
+
|
|
12
|
+
def refresh_data
|
|
13
|
+
refresh_data_for_stats
|
|
14
|
+
refresh_data_for_set
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative "base_tab"
|
|
2
|
+
require_relative "set_tab"
|
|
3
|
+
|
|
4
|
+
module Sidekiq
|
|
5
|
+
class TUI
|
|
6
|
+
module Tabs
|
|
7
|
+
class Scheduled < BaseTab
|
|
8
|
+
include SetTab
|
|
9
|
+
|
|
10
|
+
def set_class = Sidekiq::ScheduledSet
|
|
11
|
+
|
|
12
|
+
def refresh_data
|
|
13
|
+
refresh_data_for_stats
|
|
14
|
+
refresh_data_for_set
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
module Sidekiq
|
|
2
|
+
class TUI
|
|
3
|
+
module Tabs
|
|
4
|
+
module SetTab
|
|
5
|
+
include Sidekiq::Paginator
|
|
6
|
+
include Filtering
|
|
7
|
+
|
|
8
|
+
def features
|
|
9
|
+
%i[selectable pageable filterable]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def controls
|
|
13
|
+
@controls ||= super + [{code: "D", modifiers: ["shift"], display: "D", description: "Delete",
|
|
14
|
+
action: ->(tui, tab) { tab.alter_rows!(:delete) }, refresh: true},
|
|
15
|
+
{code: "R", modifiers: ["shift"], display: "R", description: "Retry",
|
|
16
|
+
action: ->(tui, tab) { tab.alter_rows!(:retry) }, refresh: true},
|
|
17
|
+
{code: "E", modifiers: ["shift"], display: "E", description: "Enqueue",
|
|
18
|
+
action: ->(tui, tab) { tab.alter_rows!(:add_to_queue) }, refresh: true},
|
|
19
|
+
{code: "K", modifiers: ["shift"], display: "K", description: "Kill",
|
|
20
|
+
action: ->(tui, tab) { tab.alter_rows!(:kill) }, refresh: true}]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def alter_rows!(action)
|
|
24
|
+
# log(to_s, @data[:selected])
|
|
25
|
+
set = set_class.new
|
|
26
|
+
each_selection do |id|
|
|
27
|
+
score, jid = id.split("|")
|
|
28
|
+
item = set.fetch(score, jid)&.first
|
|
29
|
+
item&.send(action)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def refresh_data_for_set
|
|
34
|
+
set = set_class.new
|
|
35
|
+
f = current_filter
|
|
36
|
+
pager, rows, current, total = if f && f.size > 2
|
|
37
|
+
rows = set.scan(f).to_a
|
|
38
|
+
sz = rows.size
|
|
39
|
+
[Sidekiq::TUI::PageOptions.new(1, sz), rows, 1, sz]
|
|
40
|
+
else
|
|
41
|
+
pager = @data.dig(:table, :pager) || Sidekiq::TUI::PageOptions.new(1, 25)
|
|
42
|
+
current, total, items = page(set.name, pager.page, pager.size)
|
|
43
|
+
rows = items.map { |msg, score| Sidekiq::SortedEntry.new(nil, score, msg) }
|
|
44
|
+
[pager, rows, current, total]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@data.merge!(
|
|
48
|
+
table: {pager:, rows:, current_page: current, total:,
|
|
49
|
+
next_page: (current * pager.size < total) ? pager.page + 1 : nil,
|
|
50
|
+
row_ids: rows.map { |job| [job.score, job["jid"]].join("|") }}
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def render(tui, frame, area)
|
|
55
|
+
chunks = tui.layout_split(
|
|
56
|
+
area,
|
|
57
|
+
direction: :vertical,
|
|
58
|
+
constraints: [
|
|
59
|
+
tui.constraint_length(4), # Stats
|
|
60
|
+
tui.constraint_fill(1) # Table
|
|
61
|
+
]
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
render_stats_section(tui, frame, chunks[0])
|
|
65
|
+
render_table(tui, frame, chunks[1]) do
|
|
66
|
+
{
|
|
67
|
+
title: t(name),
|
|
68
|
+
header: ["☑️", "When", "Queue", "Job", "Arguments"].map { |x| t(x) },
|
|
69
|
+
widths: [
|
|
70
|
+
tui.constraint_length(5),
|
|
71
|
+
tui.constraint_length(24),
|
|
72
|
+
tui.constraint_length(20),
|
|
73
|
+
tui.constraint_length(30),
|
|
74
|
+
tui.constraint_fill(1)
|
|
75
|
+
]
|
|
76
|
+
}.tap do |h|
|
|
77
|
+
rows = @data[:table][:rows].map.with_index { |entry, idx|
|
|
78
|
+
tui.table_row(
|
|
79
|
+
cells: [
|
|
80
|
+
selected?(entry) ? "✅" : "",
|
|
81
|
+
entry.at,
|
|
82
|
+
entry.queue,
|
|
83
|
+
entry.display_class,
|
|
84
|
+
entry.display_args
|
|
85
|
+
],
|
|
86
|
+
style: idx.even? ? nil : tui.style(bg: :dark_gray)
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
h[:rows] = rows
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require_relative "tabs/home"
|
|
2
|
+
require_relative "tabs/busy"
|
|
3
|
+
require_relative "tabs/queues"
|
|
4
|
+
require_relative "tabs/scheduled"
|
|
5
|
+
require_relative "tabs/retries"
|
|
6
|
+
require_relative "tabs/dead"
|
|
7
|
+
require_relative "tabs/metrics"
|
|
8
|
+
|
|
9
|
+
module Sidekiq
|
|
10
|
+
class TUI
|
|
11
|
+
module Tabs
|
|
12
|
+
All = Set.new([Home, Busy, Queues, Scheduled, Retries, Dead, Metrics])
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|