solid_queue
solid_queue copied to clipboard
option for silencing logging for heartbeats
In development, and possible other environments, it's sometimes nice to not see the heartbeat logging. This adds an option to silence the logging for heartbeats. It's very similar to the "silence_polling" option.
Usage:
config.solid_queue.silence_heartbeats = true
Thanks @jlvallelonga! However, I was hoping we could get https://github.com/rails/solid_queue/issues/210 done instead of having a bunch of different options to silence different parts 😅
Yeah I was thinking about that a bit when I was doing this. Makes sense :)
For me, silence_polling and silence_heartbeat_logging address different concerns. In that sense, we can keep them as two separate settings. Any chance we can merge this? @rosa
In the meantime, I've monkeypatched this PR:
# /config/initializers/solid_queue.rb
module SilenceHeartbeat
def heartbeat
ActiveRecord::Base.logger.silence do
# Clear any previous changes before locking, for example, in case a previous heartbeat
# failed because of a DB issue (with SQLite depending on configuration, a BusyException
# is not rare) and we still have the unpersisted value
restore_attributes
with_lock { touch(:last_heartbeat_at) }
end
end
end
Rails.application.config.to_prepare do
SolidQueue::Process.prepend(SilenceHeartbeat) unless Rails.env.production?
end
Many tnx @jlvallelonga
That work's great Jean-Baptiste to silence the heartbeat logging that happens every minute.
You can also significantly reduce the 5-minute "Prune dead processes" logs by adding to config/environments/development.rb something like
config.solid_queue.process_alive_threshold = 1.day
But I've found that bad things happen if you try to get rid if the 10-minute "Unblock jobs" logging by any setting of concurrency_maintenance_interval in config/queue.yml.