Module: Sidekiq::Belt::Community::ForceKill::SidekiqForceKill

Defined in:
lib/sidekiq/belt/community/force_kill.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sidekiq/belt/community/force_kill.rb', line 15

def self.registered(app)
  app.replace_content("/busy") do |content|
    content.gsub!("<%= t('Stop') %></button>") do
      "<%= t('Stop') %></button>" \
        "<% if process.stopping? %>" \
        "<a href=\"<%= root_path %>/force_kill/<%= process['identity'] %>/kill\" " \
        "class=\"btn btn-xs btn-danger\" data-confirm=\"<%= t('AreYouSure') %>\">" \
        "<%= t('Kill') %></a>" \
        "<% end %>"
    end
  end

  app.get("/force_kill/:identity/kill") do
    process = Sidekiq::ProcessSet[route_params(:identity)]

    if process
      process.stop!
      process.kill!
    end

    return redirect "#{root_path}busy"
  end
end