2014-07-21 22:14:18 +08:00
|
|
|
#!/usr/bin/ruby
|
2012-09-05 05:42:13 +08:00
|
|
|
# encoding: UTF-8
|
|
|
|
#
|
|
|
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify it under the
|
|
|
|
# terms of the GNU Lesser General Public License as published by the Free Software
|
|
|
|
# Foundation; either version 3.0 of the License, or (at your option) any later
|
|
|
|
# version.
|
|
|
|
#
|
|
|
|
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License along
|
|
|
|
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2017-07-11 05:18:39 +08:00
|
|
|
require File.expand_path('../../../lib/recordandplayback', __FILE__)
|
2012-08-21 07:12:58 +08:00
|
|
|
require 'logger'
|
|
|
|
require 'trollop'
|
|
|
|
require 'yaml'
|
2012-08-14 04:22:53 +08:00
|
|
|
require "nokogiri"
|
2012-08-16 08:10:29 +08:00
|
|
|
require "redis"
|
|
|
|
require "fileutils"
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2019-12-05 02:35:08 +08:00
|
|
|
props = BigBlueButton.read_props
|
2018-05-23 23:18:04 +08:00
|
|
|
log_dir = props['log_dir']
|
|
|
|
audio_dir = props['raw_audio_src']
|
|
|
|
recording_dir = props['recording_dir']
|
|
|
|
raw_archive_dir = "#{recording_dir}/raw"
|
|
|
|
redis_host = props['redis_host']
|
|
|
|
redis_port = props['redis_port']
|
2018-12-15 06:16:12 +08:00
|
|
|
redis_password = props['redis_password']
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
opts = Trollop::options do
|
|
|
|
opt :meeting_id, "Meeting id to archive", type: :string
|
|
|
|
opt :break_timestamp, "Chapter break end timestamp", type: :string
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
2018-05-23 23:18:04 +08:00
|
|
|
Trollop::die :meeting_id, "must be provided" if opts[:meeting_id].nil?
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
meeting_id = opts[:meeting_id]
|
|
|
|
break_timestamp = opts[:break_timestamp]
|
2013-07-16 04:22:39 +08:00
|
|
|
|
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
BigBlueButton.logger = Logger.new("#{log_dir}/sanity.log", 'daily' )
|
|
|
|
logger = BigBlueButton.logger
|
2013-07-16 04:22:39 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
def check_events_xml(raw_dir,meeting_id)
|
|
|
|
filepath = "#{raw_dir}/#{meeting_id}/events.xml"
|
|
|
|
raise Exception, "Events file doesn't exists." if not File.exists?(filepath)
|
|
|
|
bad_doc = Nokogiri::XML(File.open(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
|
2013-04-05 04:08:49 +08:00
|
|
|
end
|
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
def repair_red5_ser(directory)
|
|
|
|
cp="/usr/share/red5/red5-server.jar:/usr/share/red5/lib/*"
|
|
|
|
if File.directory?(directory)
|
|
|
|
FileUtils.cd(directory) do
|
|
|
|
|
|
|
|
BigBlueButton.logger.info("Repairing red5 serialized streams")
|
|
|
|
Dir.glob("*.flv.ser").each do |ser|
|
|
|
|
BigBlueButton.logger.info("Repairing #{ser}")
|
|
|
|
ret = BigBlueButton.exec_ret('java', '-cp', cp, 'org.red5.io.flv.impl.FLVWriter', ser, '0', '7')
|
|
|
|
if ret != 0
|
|
|
|
BigBlueButton.logger.warn("Failed to repair #{ser}")
|
2018-05-24 00:03:20 +08:00
|
|
|
next
|
2017-01-21 02:23:36 +08:00
|
|
|
end
|
|
|
|
|
2018-05-24 00:03:20 +08:00
|
|
|
BigBlueButton.logger.info("Cleaning up .flv.ser and .flv.info files")
|
|
|
|
FileUtils.rm_f(ser)
|
|
|
|
FileUtils.rm_f("#{ser[0..-5]}.info")
|
2018-05-23 23:18:04 +08:00
|
|
|
end
|
2013-04-05 04:08:49 +08:00
|
|
|
end
|
2018-05-16 23:27:12 +08:00
|
|
|
end
|
2013-04-05 04:08:49 +08:00
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
# Determine the filenames for the done and fail files
|
|
|
|
if !break_timestamp.nil?
|
|
|
|
done_base = "#{meeting_id}-#{break_timestamp}"
|
|
|
|
else
|
|
|
|
done_base = meeting_id
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
2018-05-23 23:18:04 +08:00
|
|
|
sanity_done_file = "#{recording_dir}/status/sanity/#{done_base}.done"
|
|
|
|
sanity_fail_file = "#{recording_dir}/status/sanity/#{done_base}.fail"
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2014-04-08 03:14:47 +08:00
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
begin
|
2018-05-23 23:18:04 +08:00
|
|
|
logger.info("Starting sanity check for recording #{meeting_id}")
|
|
|
|
if !break_timestamp.nil?
|
|
|
|
logger.info("Break timestamp is #{break_timestamp}")
|
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
logger.info("Checking events.xml")
|
|
|
|
check_events_xml(raw_archive_dir,meeting_id)
|
2014-04-08 03:14:47 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
logger.info("Repairing webcam videos")
|
|
|
|
repair_red5_ser("#{raw_archive_dir}/#{meeting_id}/video/#{meeting_id}")
|
|
|
|
|
|
|
|
logger.info("Repairing deskshare videos")
|
|
|
|
repair_red5_ser("#{raw_archive_dir}/#{meeting_id}/deskshare")
|
|
|
|
|
|
|
|
if break_timestamp.nil?
|
|
|
|
# Either this recording isn't segmented, or we are working on the last
|
|
|
|
# segment, so go ahead and clean up all the redis data.
|
|
|
|
logger.info("Deleting keys")
|
2018-12-15 06:16:12 +08:00
|
|
|
redis = BigBlueButton::RedisWrapper.new(redis_host, redis_port, redis_password)
|
2018-05-23 23:18:04 +08:00
|
|
|
events_archiver = BigBlueButton::RedisEventsArchiver.new(redis)
|
2014-04-04 04:23:49 +08:00
|
|
|
events_archiver.delete_events(meeting_id)
|
2018-05-23 23:18:04 +08:00
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
|
2018-05-23 23:18:04 +08:00
|
|
|
logger.info("creating sanity done files")
|
|
|
|
File.open(sanity_done_file, "w") do |sanity_done|
|
|
|
|
sanity_done.write("sanity check #{meeting_id}")
|
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
rescue Exception => e
|
2018-05-23 23:18:04 +08:00
|
|
|
BigBlueButton.logger.error("error in sanity check: " + e.message)
|
|
|
|
BigBlueButton.logger.error(e.backtrace.join("\n"))
|
|
|
|
File.open(sanity_fail_file, "w") do |sanity_fail|
|
|
|
|
sanity_fail.write("error: " + e.message)
|
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
end
|
2012-08-14 04:22:53 +08:00
|
|
|
|
|
|
|
|