Sha256: dbd5077e4f54d421515c827175a68a6fd62e57cda2d12252f8903f30b6e29b1e

Contents?: true

Size: 1.17 KB

Versions: 21

Compression:

Stored size: 1.17 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 "conchita disabled" if disabled?(@config[:timer])
      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
      RestFtpDaemon::JobQueue.instance.expire JOB_STATUS_FINISHED,  maxage(JOB_STATUS_FINISHED),  @config[:debug]
      RestFtpDaemon::JobQueue.instance.expire JOB_STATUS_FAILED,    maxage(JOB_STATUS_FAILED),    @config[:debug]
      RestFtpDaemon::JobQueue.instance.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

21 entries across 21 versions & 1 rubygems

Version Path
rest-ftp-daemon-1.1.1 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.1.0 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.15 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.14 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.13 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.12 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.11 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.10 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.9 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.8 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.7 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.6 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.5 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.4 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.3 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.2 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-1.0.1 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.502.2 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.502.1 lib/rest-ftp-daemon/workers/conchita.rb
rest-ftp-daemon-0.502.0 lib/rest-ftp-daemon/workers/conchita.rb