From f2deb3e13f44070f4db25a723729caf152e54835 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 18 Oct 2023 13:57:04 -0400 Subject: [PATCH] Fix issue that would cause the poller not to panic correctly (#1030) --- lib/tasks/poll.rake | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/tasks/poll.rake b/lib/tasks/poll.rake index 7ae1f74a..1a0ad16a 100644 --- a/lib/tasks/poll.rake +++ b/lib/tasks/poll.rake @@ -96,10 +96,26 @@ namespace :poll do next if server.increment_unhealthy < Rails.configuration.x.server_unhealthy_threshold Rails.logger.warn("Server id=#{server.id} is unhealthy. Panicking and setting offline...") - Rake::Task['servers:panic'].invoke(server.id, true) # Panic server to clear meetings + + meetings = Meeting.all.select { |m| m.server_id == server.id } + meetings.each do |meeting| + puts("Clearing Meeting id=#{meeting.id}") + moderator_pw = meeting.try(:moderator_pw) + meeting.destroy! + get_post_req(encode_bbb_uri('end', server.url, server.secret, meetingID: meeting.id, password: moderator_pw)) + rescue ApplicationRedisRecord::RecordNotDestroyed => e + raise("ERROR: Could not destroy meeting id=#{meeting.id}: #{e}") + rescue StandardError => e + puts("WARNING: Could not end meeting id=#{meeting.id}: #{e}") + end + server.reset_counters server.load = nil server.online = false + server.meetings = 0 + server.users = 0 + server.largest_meeting = 0 + server.videos = 0 ensure begin server.save!