19 lines
559 B
Ruby
19 lines
559 B
Ruby
|
# config/initializers/schedule_tasks.rb
|
||
|
|
||
|
Rails.application.config.after_initialize do
|
||
|
if Rails.env.production?
|
||
|
begin
|
||
|
unless Rails.cache.read("startup_task_running")
|
||
|
Rails.cache.write("startup_task_running", true, expires_in: 1.hour)
|
||
|
|
||
|
RefreshSitemapWorker.perform_async
|
||
|
|
||
|
Rails.logger.info "Startup task (RefreshSitemapWorker) scheduled successfully"
|
||
|
end
|
||
|
rescue => e
|
||
|
Rails.logger.error "Error scheduling startup task: #{e.message}"
|
||
|
ensure
|
||
|
Rails.cache.delete("startup_task_running")
|
||
|
end
|
||
|
end
|
||
|
end
|