Sha256: 983823b8767437a84ff6ee05360a0bfaa31907217bee8a88c97c542d9561bf9b
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require "benchmark" module ErpTechSvcs module DelayedJobs # Delayed Job to Reset Daily Assignments to Forecast class DeleteExpiredSessionsJob def initialize @priority = 1 end def perform unless Dir.exists?(File.join(Rails.root, 'log/delayed_jobs')) Dir.mkdir(File.join(Rails.root, 'log/delayed_jobs')) end logger = Logger.new(File.join(Rails.root,"log/delayed_jobs/#{Rails.env}-delete_expired_sessions_job.log"), "weekly") logger.level = Logger::INFO time = Benchmark.measure do begin ActiveRecord::SessionStore::Session.delete_all ['updated_at < ?', ErpTechSvcs::Config.session_expires_in_hours.hours.ago] rescue => ex logger.error("#{Time.now}**************************************************") logger.error("Job Error: #{ex.message}") logger.error("Trace: #{ex.backtrace.join("\n")}") logger.error("*************************************************************") # email notification ExceptionNotifier.notify_exception(ex) if defined? ExceptionNotifier end end #benchmark # Run once per day start_time = Time.now + 1.day Delayed::Job.enqueue(DeleteExpiredSessionsJob.new, @priority, start_time) # Update job tracker JobTracker.job_ran('Delete Expired Sessions', self.class.name, ("(%.4fs)" % time.real), start_time) end def self.schedule_job(schedule_dt) Delayed::Job.enqueue(DeleteExpiredSessionsJob.new, @priority, schedule_dt) end end # DeleteExpiredSessionsJob end # DelayedJobs end # ErpTechSvcs
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
erp_tech_svcs-4.2.0 | lib/erp_tech_svcs/delayed_jobs/delete_expired_sessions_job.rb |