hensei-api/config/initializers/scheduler.rb
Justin Edmund 1c1ed0dd9d
Work towards fixing embed images (#174)
* Add Redis and Sidekiq

* Rename PreviewGenerationMonitor

* Update production.rb

require master key

* Initialize AWS at application start

* Add fallbacks for credentials

* Add logging

* Create railway.toml
2025-01-18 11:46:41 -08:00

18 lines
485 B
Ruby

require 'rufus-scheduler'
# Don't schedule jobs in test environment or when running rake tasks
unless defined?(Rails::Console) || Rails.env.test? || File.split($0).last == 'rake'
scheduler = Rufus::Scheduler.new
scheduler.every '5m' do
PreviewService::GenerationMonitor.check_stalled_jobs
end
scheduler.every '1h' do
PreviewService::GenerationMonitor.retry_failed
end
scheduler.every '1d' do
PreviewService::GenerationMonitor.cleanup_old_previews
end
end