Sha256: 87610bdd7f984deafcacc1171a37f0a9e57cdbdbe503131b98e1ea936db45406

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module RestFtpDaemon

  # Worker used to clean up the queue deleting expired jobs
  class ConchitaWorker < Worker

    def initialize wid, pool = nil
      # Call dady and load my conf
      super

      # Start main loop
      log_info "#{self.class.name} starting", @config
      start
    end

  protected

    # def log_prefix
    #  [
    #   Thread.current.thread_variable_get(:wid),
    #   nil,
    #   nil
    #   ]
    # end

    def work
      # Announce we are working
      worker_status WORKER_STATUS_CLEANING

      # Cleanup queues according to configured max-age
      $queue.expire JOB_STATUS_FINISHED,  maxage(JOB_STATUS_FINISHED),  @debug
      $queue.expire JOB_STATUS_FAILED,    maxage(JOB_STATUS_FAILED),    @debug
      $queue.expire JOB_STATUS_QUEUED,    maxage(JOB_STATUS_QUEUED),    @debug

      # Force garbage collector
      GC.start if @config["garbage_collector"]

    rescue StandardError => e
      log_error "EXCEPTION: #{e.inspect}"
      sleep 1
    else
      wait_according_to_config
    end

    def maxage status
      @config["clean_#{status}"] || 0
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.300.3 lib/rest-ftp-daemon/worker_conchita.rb
rest-ftp-daemon-0.300.2 lib/rest-ftp-daemon/worker_conchita.rb
rest-ftp-daemon-0.300.1 lib/rest-ftp-daemon/worker_conchita.rb