Sha256: b167de51fc49ea0562f7cc4a516748c1fc183e423d7b5ef2d439f9ebe7d31a7a

Contents?: true

Size: 654 Bytes

Versions: 11

Compression:

Stored size: 654 Bytes

Contents

module PgHero
  module Methods
    module Kill
      def kill(pid)
        PgHero.truthy? execute("SELECT pg_terminate_backend(#{pid.to_i})").first["pg_terminate_backend"]
      end

      def kill_long_running_queries
        long_running_queries.each { |query| kill(query["pid"]) }
        true
      end

      def kill_all
        select_all <<-SQL
          SELECT
            pg_terminate_backend(pid)
          FROM
            pg_stat_activity
          WHERE
            pid <> pg_backend_pid()
            AND query <> '<insufficient privilege>'
            AND datname = current_database()
        SQL
        true
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pghero-1.7.0 lib/pghero/methods/kill.rb
pghero-1.6.5 lib/pghero/methods/kill.rb
pghero-1.6.4 lib/pghero/methods/kill.rb
pghero-1.6.3 lib/pghero/methods/kill.rb
pghero-1.6.2 lib/pghero/methods/kill.rb
pghero-1.6.1 lib/pghero/methods/kill.rb
pghero-1.6.0 lib/pghero/methods/kill.rb
pghero-1.5.3 lib/pghero/methods/kill.rb
pghero-1.5.2 lib/pghero/methods/kill.rb
pghero-1.5.1 lib/pghero/methods/kill.rb
pghero-1.5.0 lib/pghero/methods/kill.rb