Sha256: 625614b355760adb6f7ce286197048df6eae19adbeaecbc3904694ffb5c08488
Contents?: true
Size: 798 Bytes
Versions: 4
Compression:
Stored size: 798 Bytes
Contents
require 'get_process_mem' module Delayed class Master module Plugins class MemoryChecker < Delayed::Plugin callbacks do |lifecycle| lifecycle.before(:perform) do |worker, job| mem = GetProcessMem.new worker.master_logger.info "performing #{job.name}, memory: #{mem.mb.to_i} MB" end lifecycle.after(:perform) do |worker, job| mem = GetProcessMem.new worker.master_logger.info "performed #{job.name}, memory: #{mem.mb.to_i} MB" if worker.max_memory && mem.mb > worker.max_memory worker.master_logger.info "shutting down worker #{Process.pid} because it consumes large memory..." worker.stop end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems