DEV: Ensure Sidekiq logging thread is always running (#17211)
This commit is contained in:
parent
d1d6868325
commit
4199ada1ce
|
@ -97,14 +97,19 @@ module Jobs
|
||||||
f.sync = true
|
f.sync = true
|
||||||
Logger.new f
|
Logger.new f
|
||||||
end
|
end
|
||||||
|
|
||||||
@@log_queue ||= Queue.new
|
@@log_queue ||= Queue.new
|
||||||
@@log_thread ||= Thread.new do
|
|
||||||
begin
|
if !@@log_thread || !@@log_thead.alive?
|
||||||
loop { @@logger << @@log_queue.pop }
|
@@log_thread = Thread.new do
|
||||||
rescue Exception => e
|
loop do
|
||||||
Discourse.warn_exception(e, message: "Sidekiq logging thread terminated unexpectedly")
|
@@logger << @@log_queue.pop
|
||||||
|
rescue Exception => e
|
||||||
|
Discourse.warn_exception(e, message: "Exception encountered while logging Sidekiq job")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@log_queue.push(message)
|
@@log_queue.push(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue