Sha256: ccf3924d3b678508509ef0a7b10c59778de1628b8f2a0e47a0007c3a7e7d9b72

Contents?: true

Size: 795 Bytes

Versions: 2

Compression:

Stored size: 795 Bytes

Contents

engine :fork 
workers 2

pool :daemonizer do
  workers 4
  poll_period 5
  log_file "log/daemonizer.log" #relative to Demfile
  
  before_init do |logger, block|
    block.call
  end
  
  after_init do |logger, worker_id, workers_count|
    logger.info "Started #{worker_id} from #{workers_count}"
    
    exit = false
    
    stop = proc {
      exit = true
    }

    trap('TERM', stop)
    trap('INT', stop)
    trap('EXIT', stop)
    
    loop do
      break if exit
      logger.info "Ping #{worker_id}"
      sleep 10
    end
    
    true
  end
end

pool :new_daemonizer do
  workers 4
  poll_period 5
  log_file "log/daemonizer.log" #relative to Demfile

  handler ::AsyncObserver::DaemonizerHandler
  
  set_option :queue, lambda { |worker_id, worker_count| "queue_#{worker_id}"}
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
daemonizer-0.0.7 README
daemonizer-0.0.6 README