Skip to content

Commit

Permalink
Occasionally print the names of running background tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Jul 29, 2024
1 parent 78ca915 commit 20ee525
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions script/background_daemon
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ Rails.logger.info 'Starting background_daemon'
# block other ones.
processes = BackgroundTaskRegistry.all_tasks.map do |task|
Process.fork do
last_reminder_time = nil
loop do
begin
if last_reminder_time.nil? || Time.zone.now - last_reminder_time > 10.minutes
Rails.logger.info "Occasional reminder that #{task.class.name} is running."
last_reminder_time = Time.zone.now
end
task.run
rescue StandardError => e
Rails.logger.error "#{task.class.name} exception: " + exception_to_str(e)
Expand Down

0 comments on commit 20ee525

Please sign in to comment.