Sha256: 08fe6101d84531253e5f414cb0a3f8a40a8b42d6fb72fb10b41f029e43db1221

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + "/../../config/environment"

Signal.trap("TERM") { exit }

if Job.included_modules.include?(Job::BonusFeatures)
  RAILS_DEFAULT_LOGGER.info("BackgroundFu: Starting daemon (bonus features enabled).")
else
  RAILS_DEFAULT_LOGGER.info("BackgroundFu: Starting daemon (bonus features disabled).")
end

loop do
  if job = Job.find(:first, :conditions => ["state='pending' and start_at <= ?", Time.now.utc], :order => "priority desc, start_at asc")
    job.get_done!
  else
    RAILS_DEFAULT_LOGGER.info("BackgroundFu: Waiting for jobs...")
    sleep 5
  end
  
  Job.destroy_all(["state='finished' and updated_at < ?", 1.week.ago])
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
genki-background_fu-1.0.8.2 generators/background/templates/background.rb
ncr-background_fu-1.0.8 generators/background/templates/background.rb