songtianlun
1ca468f9af
- Add error handling when scheduling the RefreshSitemapWorker in production. - Log successful scheduling and errors for improved diagnostics. This change ensures that any issues with scheduling the worker are logged and can be addressed promptly, enhancing the reliability of the application in production.
12 lines
378 B
Ruby
12 lines
378 B
Ruby
# config/initializers/schedule_tasks.rb
|
|
Rails.application.config.after_initialize do
|
|
if Rails.env.production? && !ENV["RAILS_BUILD"]
|
|
begin
|
|
RefreshSitemapWorker.perform_async
|
|
Rails.logger.info "Startup task (RefreshSitemapWorker) scheduled successfully"
|
|
rescue => e
|
|
Rails.logger.error "Error scheduling startup task: #{e.message}"
|
|
end
|
|
end
|
|
end
|