today_ai_weather/config/initializers/schedule_tasks.rb
songtianlun dd37e2835b style: add newline at end of schedule_tasks.rb
This commit adds a newline at the end of the 'schedule_tasks.rb' file to comply with the standard coding practices. Proper file formatting helps in maintaining code consistency across the project.
2025-01-25 01:38:35 +08:00

20 lines
583 B
Ruby

# config/initializers/schedule_tasks.rb
Rails.application.config.after_initialize do
if Rails.env.production? && !ENV["RAILS_BUILD"]
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