songtianlun
dd37e2835b
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.
20 lines
583 B
Ruby
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
|