class RestFtpDaemon::ConchitaWorker

Protected Instance Methods

worker_after() click to toggle source
# File lib/rest-ftp-daemon/workers/conchita.rb, line 18
def worker_after
  # Sleep for a few seconds
  worker_status WORKER_STATUS_WAITING
  sleep @config[:timer]
end
worker_init() click to toggle source
# File lib/rest-ftp-daemon/workers/conchita.rb, line 8
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
worker_process() click to toggle source
# File lib/rest-ftp-daemon/workers/conchita.rb, line 24
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 Instance Methods

maxage(status) click to toggle source
# File lib/rest-ftp-daemon/workers/conchita.rb, line 39
def maxage status
  @config["clean_#{status}"] || 0
end