ensure that activity log keep alive thread is started per worker

This commit is contained in:
Sebastian Jambor 2023-04-18 19:20:11 +00:00
parent 3d34d5d2b2
commit fd2f4ba76c
2 changed files with 15 additions and 9 deletions

View file

@ -18,6 +18,7 @@ class ActivityLogger
rescue
puts 'rescued'
logger.close
ActivityLogger.unregister(id, logger)
puts 'closed logger'
end
end
@ -26,14 +27,17 @@ class ActivityLogger
@@loggers.clear
end
Thread.new {
while true
event = ActivityLogEvent.new('keep-alive', nil, nil, nil)
@@loggers.each_key do |key|
ActivityLogger.log(key, event)
end
def self.start_keep_alive_thread
Thread.new {
while true
event = ActivityLogEvent.new('keep-alive', nil, nil, nil)
puts "writing keep-alive"
@@loggers.each_key do |key|
ActivityLogger.log(key, event)
end
sleep 10
end
}
sleep 10
end
}
end
end

View file

@ -25,6 +25,8 @@ on_worker_boot do
Thread.new {
ActivityLogSubscriber.new.start
}
ActivityLogger.start_keep_alive_thread
end
plugin :tmp_restart