Sha256: 69ee21307a03cbb8e0ac33f38048ec988e75330026264e8fd351694ba6fe7961

Contents?: true

Size: 874 Bytes

Versions: 3

Compression:

Stored size: 874 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

  before_init do |logger, block|
    logger.info "New: Preparing master process"
    block.call
  end
  
  after_init do |logger, worker_id, workers_count|
    logger.info "Started #{worker_id}/#{workers_count}"
    sleep 1
    logger.info "Stopped #{worker_id}/#{workers_count}"
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
daemonizer-0.0.4 README
daemonizer-0.0.3 README
daemonizer-0.0.2 README