sidekiq-belt 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -2
- data/lib/sidekiq/belt/community/files.rb +2 -0
- data/lib/sidekiq/belt/community/force_kill.rb +47 -0
- data/lib/sidekiq/belt/version.rb +1 -1
- data/lib/sidekiq/web_action_helper.rb +18 -8
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9378b2263842e78c94a366b421fc26062c1ca3c38587543c96ebb3760701be9f
|
4
|
+
data.tar.gz: 605d1139e12eb82ac048a790802313338906c452f2c171a7c6bcee48cb6cc7cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10989d5396c5bdaf8435849dbb8ed1c5a4fd69331d4fae57f56a38b30c51d692bf86a9c1ef8503029ee20eb52f82e294b43c0957ec08f0a5b5d62677a5200ca4
|
7
|
+
data.tar.gz: 89323ca938d21925726c6fcc8c532160172a094e3c9bee2c7c56f493dcb914ae79dc4dfd4ca5bef5529520ced2ece334713ba8f0c24c8e7526c8c55ac9c13058
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -116,7 +116,7 @@ Sidekiq::Belt.configure do |config|
|
|
116
116
|
end
|
117
117
|
```
|
118
118
|
|
119
|
-
### Add to your web sidekiq a top label by
|
119
|
+
### Add to your web sidekiq a top label by environment (sidekiq)
|
120
120
|
|
121
121
|
This feature adds a little line on top of Sidekiq web that shows a configurable message.
|
122
122
|
|
@@ -133,7 +133,7 @@ Sidekiq::Belt.configure do |config|
|
|
133
133
|
config.top_label = {
|
134
134
|
production: {
|
135
135
|
background_color: 'red',
|
136
|
-
text: 'Be
|
136
|
+
text: 'Be careful',
|
137
137
|
color: 'white'
|
138
138
|
},
|
139
139
|
development: {
|
@@ -4,6 +4,7 @@ require "sidekiq"
|
|
4
4
|
|
5
5
|
require_relative "run_job"
|
6
6
|
require_relative "top_label"
|
7
|
+
require_relative "force_kill"
|
7
8
|
|
8
9
|
module Sidekiq
|
9
10
|
module Belt
|
@@ -12,6 +13,7 @@ module Sidekiq
|
|
12
13
|
def self.use!(options = [:all])
|
13
14
|
Sidekiq::Belt::Community::RunJob.use! if should_use?(:run_job, options)
|
14
15
|
Sidekiq::Belt::Community::TopLabel.use! if should_use?(:top_label, options)
|
16
|
+
Sidekiq::Belt::Community::ForceKill.use! if should_use?(:force_kill, options)
|
15
17
|
|
16
18
|
true
|
17
19
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq/web"
|
4
|
+
require "sidekiq/web/helpers"
|
5
|
+
|
6
|
+
module Sidekiq
|
7
|
+
module Belt
|
8
|
+
module Community
|
9
|
+
module ForceKill
|
10
|
+
def kill!
|
11
|
+
signal("KILL")
|
12
|
+
end
|
13
|
+
|
14
|
+
module SidekiqForceKill
|
15
|
+
def self.registered(app)
|
16
|
+
app.replace_content("/busy") do |content|
|
17
|
+
content.gsub!("<%= t('Stop') %></button>") do
|
18
|
+
"<%= t('Stop') %></button>" \
|
19
|
+
"<% if process.stopping? %>" \
|
20
|
+
"<a href=\"<%= root_path %>/force_kill/<%= process['identity'] %>/kill\" " \
|
21
|
+
"class=\"btn btn-xs btn-danger\" data-confirm=\"<%= t('AreYouSure') %>\">" \
|
22
|
+
"<%= t('Kill') %></a>" \
|
23
|
+
"<% end %>"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
app.get("/force_kill/:identity/kill") do
|
28
|
+
process = Sidekiq::ProcessSet[params["identity"]]
|
29
|
+
|
30
|
+
if process
|
31
|
+
process.stop!
|
32
|
+
process.kill!
|
33
|
+
end
|
34
|
+
|
35
|
+
return redirect "#{root_path}busy"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.use!
|
41
|
+
Sidekiq::Web.register(Sidekiq::Belt::Community::ForceKill::SidekiqForceKill)
|
42
|
+
Sidekiq::Process.prepend(Sidekiq::Belt::Community::ForceKill)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/sidekiq/belt/version.rb
CHANGED
@@ -5,18 +5,28 @@ require "sidekiq/web/action"
|
|
5
5
|
|
6
6
|
module Sidekiq
|
7
7
|
module WebActionHelper
|
8
|
-
|
9
|
-
|
8
|
+
class ERB < ::ERB
|
9
|
+
def initialize(content)
|
10
|
+
replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
|
10
11
|
|
11
|
-
|
12
|
+
replace_views.each do |key, content_blocks|
|
13
|
+
next if WebRoute.new("", key, true).match("", self.class.path_info).nil?
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
content_blocks.each do |content_block|
|
17
|
-
content_block.call(content)
|
15
|
+
content_blocks.each do |content_block|
|
16
|
+
content_block.call(content)
|
17
|
+
end
|
18
18
|
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
attr_accessor :path_info
|
19
25
|
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def erb(content, options = {})
|
29
|
+
ERB.path_info = ::Rack::Utils.unescape(env["PATH_INFO"])
|
20
30
|
|
21
31
|
super
|
22
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-belt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/sidekiq-belt.rb
|
43
43
|
- lib/sidekiq/belt.rb
|
44
44
|
- lib/sidekiq/belt/community/files.rb
|
45
|
+
- lib/sidekiq/belt/community/force_kill.rb
|
45
46
|
- lib/sidekiq/belt/community/run_job.rb
|
46
47
|
- lib/sidekiq/belt/community/top_label.rb
|
47
48
|
- lib/sidekiq/belt/community/views/run_jobs.erb
|
@@ -62,7 +63,7 @@ metadata:
|
|
62
63
|
homepage_uri: https://github.com/dannnylo/sidekiq-belt
|
63
64
|
source_code_uri: https://github.com/dannnylo/sidekiq-belt
|
64
65
|
rubygems_mfa_required: 'true'
|
65
|
-
post_install_message:
|
66
|
+
post_install_message:
|
66
67
|
rdoc_options: []
|
67
68
|
require_paths:
|
68
69
|
- lib
|
@@ -78,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubygems_version: 3.5.16
|
81
|
-
signing_key:
|
82
|
+
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq
|
84
85
|
Enterprise by adding essential utilities.
|