2017-07-10 23:42:40 +08:00
|
|
|
#!/usr/bin/ruby
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
# Copyright ⓒ 2017 BigBlueButton Inc. and by respective authors.
|
|
|
|
#
|
|
|
|
# This file is part of BigBlueButton open source conferencing system.
|
|
|
|
#
|
|
|
|
# BigBlueButton 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 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.
|
2019-12-05 22:41:13 +08:00
|
|
|
#
|
2017-07-10 23:42:40 +08:00
|
|
|
# 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__)
|
2017-07-11 23:58:36 +08:00
|
|
|
require File.expand_path('../workers/workers', __FILE__)
|
2017-07-10 23:42:40 +08:00
|
|
|
require 'rubygems'
|
|
|
|
require 'yaml'
|
|
|
|
require 'fileutils'
|
|
|
|
require 'resque'
|
2019-12-05 22:41:13 +08:00
|
|
|
require 'rb-inotify'
|
2017-07-10 23:42:40 +08:00
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
def archive_recorded_meetings(done_file)
|
2017-07-10 23:42:40 +08:00
|
|
|
FileUtils.mkdir_p("#{recording_dir}/status/archived")
|
2019-12-05 22:41:13 +08:00
|
|
|
meeting_id = nil
|
|
|
|
break_timestamp = nil
|
2017-07-10 23:42:40 +08:00
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
if match = /^([0-9a-f]+-[0-9]+)$/.match(done_file)
|
|
|
|
meeting_id = match[1]
|
|
|
|
elsif match = /^([0-9a-f]+-[0-9]+)-([0-9]+)$/.match(done_file)
|
|
|
|
meeting_id = match[1]
|
|
|
|
break_timestamp = match[2]
|
|
|
|
else
|
|
|
|
BigBlueButton.logger.warn("Recording done file for #{done_file} has invalid format")
|
|
|
|
return
|
2017-07-10 23:42:40 +08:00
|
|
|
end
|
2019-12-05 22:41:13 +08:00
|
|
|
|
|
|
|
attrs = {
|
|
|
|
'meeting_id': meeting_id,
|
|
|
|
'break_timestamp': break_timestamp,
|
|
|
|
}
|
|
|
|
BigBlueButton.logger.info("Enqueuing job to archive #{attrs.inspect}")
|
|
|
|
Resque.enqueue(BigBlueButton::Resque::ArchiveWorker, attrs)
|
2017-07-10 23:42:40 +08:00
|
|
|
end
|
|
|
|
|
2017-07-11 05:18:39 +08:00
|
|
|
begin
|
|
|
|
props = BigBlueButton.read_props
|
2017-07-10 23:42:40 +08:00
|
|
|
log_dir = props['log_dir']
|
|
|
|
|
|
|
|
logger = Logger.new("#{log_dir}/bbb-rap-worker.log")
|
|
|
|
logger.level = Logger::INFO
|
|
|
|
BigBlueButton.logger = logger
|
|
|
|
|
2017-07-14 04:48:02 +08:00
|
|
|
redis_host = props['redis_workers_host'] || props['redis_host']
|
|
|
|
redis_port = props['redis_workers_port'] || props['redis_port']
|
|
|
|
Resque.redis = "#{redis_host}:#{redis_port}"
|
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
logger.debug('Running rap-trigger...')
|
2017-07-10 23:42:40 +08:00
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
recording_dir = props['recording_dir']
|
|
|
|
watch_dir = "#{recording_dir}/status/recorded/"
|
|
|
|
logger.info("Setting up inotify watch on #{watch_dir}")
|
|
|
|
notifier = INotify::Notifier.new
|
|
|
|
notifier.watch(watch_dir, :moved_to, :create) do |event|
|
|
|
|
next unless event.name.end_with?('.done')
|
2017-07-10 23:42:40 +08:00
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
id = File.basename(event.name, '.done')
|
|
|
|
logger.info "Detected recording #{id}, starting the processing"
|
|
|
|
archive_recorded_meetings(id)
|
|
|
|
FileUtils.rm_f(event.absolute_name)
|
|
|
|
end
|
2017-07-10 23:42:40 +08:00
|
|
|
|
2019-12-05 22:41:13 +08:00
|
|
|
logger.info('Waiting for new recordings...')
|
|
|
|
notifier.run
|
2017-07-10 23:42:40 +08:00
|
|
|
rescue Exception => e
|
|
|
|
BigBlueButton.logger.error(e.message)
|
|
|
|
e.backtrace.each do |traceline|
|
|
|
|
BigBlueButton.logger.error(traceline)
|
|
|
|
end
|
|
|
|
end
|