Sha256: b962babf574409e042d2c2fdcb91a3ef1c86a0dd14c5559174f0cb469842f283

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# Worker used to clean up the queue deleting expired jobs

module RestFtpDaemon
  class ConchitaWorker < Worker

  protected

    def worker_init
      # Load corker conf
      config_section :conchita

      # Check that everything is OK
      return "invalid timer" unless @config[:timer].to_i > 0
      return false
    end

    def worker_after
      # Sleep for a few seconds
      worker_status WORKER_STATUS_WAITING
      sleep @config[:timer]
    end

    def worker_process
      # 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),  @config[:debug]
      $queue.expire JOB_STATUS_FAILED,    maxage(JOB_STATUS_FAILED),    @config[:debug]
      $queue.expire JOB_STATUS_QUEUED,    maxage(JOB_STATUS_QUEUED),    @config[:debug]

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

  private

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rest-ftp-daemon-0.306.4 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.306.3 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.306.1 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.306.0 lib/rest-ftp-daemon/workers/conchita.rb