sidekiq-belt 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22715eaf1b97cc17ccba000c8afe03226a8d6c53b330eaa09e7c145b37c3ec62
4
- data.tar.gz: 539f10b1b8f408e046b908d9e88bddc092348f9c43177374f6ed716523190abf
3
+ metadata.gz: 0620ca72d8c203a723b37c5b557e3cb7ddb836572b3e55c13f915b08ade54690
4
+ data.tar.gz: 43554ce2b06473406080e4973614e93828ec814a6d4ed410e6fabd97e7d94971
5
5
  SHA512:
6
- metadata.gz: 4692c9cbf5354af3a7fd7ca42552d1da901a837dc4c59d433784127732e4edb3a4980b607875491e9f332a052aef5b714441883a77981e4cec427a09e72de0d5
7
- data.tar.gz: d592e7f91d8364cbe6df0fa786f19edfbdcc4d05a6cc4632779134dafa1854e55d872fe8c3ba50c7d617e6a83d0c8da7bd7ab6500226d34c4210c14e31ce8ab8
6
+ metadata.gz: 8de6db5e1e246a279e586378afbaf72aba5527b501642bb3e09e1b75413d2ac8b2f3242058f27155728e6627891f0e166e296ab735e6c895fba6428a4a524397
7
+ data.tar.gz: 14d4d139eef62eec7270794bcdeb73f19ea24a64980878b06b09ba2366dc9b8ad1bba77796da046962dfb648c5cfb8bdb1ac063b72d9bf6fa7c1c1497d7aeb2f
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
1
  ## [Unreleased]
2
+ ## [0.3.6] - 2024-09-27
3
+
4
+ - Added force kill to instances
2
5
 
3
6
  ## [0.3.5] - 2024-09-27
4
7
 
@@ -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,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sidekiq/web"
4
+ require "sidekiq/web/helpers"
5
+ require "byebug"
6
+
7
+ module Sidekiq
8
+ module Belt
9
+ module Community
10
+ module ForceKill
11
+ def kill!
12
+ signal("KILL")
13
+ end
14
+
15
+ module SidekiqForceKill
16
+ def self.registered(app)
17
+ app.replace_content("/busy") do |content|
18
+ content.gsub!("<%= t('Stop') %></button>") do
19
+ "<%= t('Stop') %></button>" \
20
+ "<% if process.stopping? %>" \
21
+ "<a href=\"<%= root_path %>/force_kill/<%= process['identity'] %>/kill\" " \
22
+ "class=\"btn btn-xs btn-danger\" data-confirm=\"<%= t('AreYouSure') %>\">" \
23
+ "<%= t('Kill') %></a>" \
24
+ "<% end %>"
25
+ end
26
+ end
27
+
28
+ app.get("/force_kill/:identity/kill") do
29
+ process = Sidekiq::ProcessSet[params["identity"]]
30
+
31
+ if process
32
+ process.stop!
33
+ process.kill!
34
+ end
35
+
36
+ return redirect "#{root_path}busy"
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.use!
42
+ Sidekiq::Web.register(Sidekiq::Belt::Community::ForceKill::SidekiqForceKill)
43
+ Sidekiq::Process.prepend(Sidekiq::Belt::Community::ForceKill)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sidekiq
4
4
  module Belt
5
- VERSION = "0.3.5"
5
+ VERSION = "0.3.6"
6
6
  end
7
7
  end
@@ -5,18 +5,28 @@ require "sidekiq/web/action"
5
5
 
6
6
  module Sidekiq
7
7
  module WebActionHelper
8
- def render(engine, content, options = {})
9
- path_info = ::Rack::Utils.unescape(env["PATH_INFO"])
8
+ class ERB < ::ERB
9
+ def initialize(content)
10
+ replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
10
11
 
11
- replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
12
+ replace_views.each do |key, content_blocks|
13
+ next if WebRoute.new("", key, true).match("", self.class.path_info).nil?
12
14
 
13
- replace_views.each do |key, content_blocks|
14
- next if WebRoute.new("", key, true).match("", path_info).nil?
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.5
4
+ version: 0.3.6
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-09-27 00:00:00.000000000 Z
11
+ date: 2024-10-12 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.