Files
aperonight/config/initializers/ticket_cleanup_scheduler.rb

24 lines
678 B
Ruby

# Schedule regular cleanup of expired draft tickets
#
# This will run every 10 minutes to clean up expired draft tickets
# If you're using a more sophisticated scheduler like sidekiq or whenever,
# you can move this logic there.
Rails.application.config.after_initialize do
# Only run in production and development, not in test
unless Rails.env.test?
# Schedule the cleanup job to run every 10 minutes
Thread.new do
loop do
begin
CleanupExpiredDraftsJob.perform_later
rescue => e
Rails.logger.error "Failed to schedule expired drafts cleanup: #{e.message}"
end
sleep 10.minutes
end
end
end
end