Sha256: 33f116433865aac7ca7bf6c1a314dc1d45d62aa405052fcd2d638a6af1eac473

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require "sidekiq/web"
require "sidekiq/web/helpers"

module Sidekiq
  module Belt
    module Community
      module ForceKill
        def kill!
          signal("KILL")
        end

        module SidekiqForceKill
          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[params["identity"]]

              if process
                process.stop!
                process.kill!
              end

              return redirect "#{root_path}busy"
            end
          end
        end

        def self.use!
          Sidekiq::Web.register(Sidekiq::Belt::Community::ForceKill::SidekiqForceKill)
          Sidekiq::Process.prepend(Sidekiq::Belt::Community::ForceKill)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-belt-1.0.0 lib/sidekiq/belt/community/force_kill.rb
sidekiq-belt-0.3.7 lib/sidekiq/belt/community/force_kill.rb