2012-05-04 02:56:01 +08:00
|
|
|
# Set encoding to utf-8
|
|
|
|
# encoding: UTF-8
|
|
|
|
|
2012-09-05 05:42:13 +08:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
2011-05-14 05:45:59 +08:00
|
|
|
require '../lib/recordandplayback'
|
|
|
|
require 'rubygems'
|
|
|
|
require 'yaml'
|
|
|
|
require 'fileutils'
|
|
|
|
|
2011-07-21 09:13:22 +08:00
|
|
|
logger = Logger.new("/var/log/bigbluebutton/bbb-rap-worker.log",'daily' )
|
|
|
|
logger.level = Logger::ERROR
|
|
|
|
BigBlueButton.logger = logger
|
2011-05-14 05:45:59 +08:00
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
def archive_recorded_meeting(recording_dir)
|
|
|
|
recorded_done_files = Dir.glob("#{recording_dir}/status/recorded/*.done")
|
2011-12-08 05:18:21 +08:00
|
|
|
archived_dirs = Dir.entries("#{recording_dir}/raw/") - ['.','..']
|
2011-12-07 04:22:35 +08:00
|
|
|
|
|
|
|
recorded_done_files.each do |df|
|
|
|
|
match = /(.*).done/.match df.sub(/.+\//, "")
|
|
|
|
meeting_id = match[1]
|
|
|
|
|
2011-12-08 05:18:21 +08:00
|
|
|
is_archived = archived_dirs.any? { |s| s.include?(meeting_id) }
|
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
if(!is_archived)
|
|
|
|
command = "ruby archive/archive.rb -m #{meeting_id}"
|
|
|
|
BigBlueButton.execute(command)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-06-07 02:42:38 +08:00
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
def sanity_archived_meeting(recording_dir)
|
|
|
|
archived_done_files = Dir.glob("#{recording_dir}/status/archived/*.done")
|
2012-08-21 07:12:58 +08:00
|
|
|
sanity_done_files = Dir.glob("#{recording_dir}/status/sanity/*.done")
|
2012-08-22 05:55:41 +08:00
|
|
|
sanity_failed_files = Dir.glob("#{recording_dir}/status/sanity/*.fail")
|
2012-08-16 08:10:29 +08:00
|
|
|
|
|
|
|
archived_done_files.each do |df|
|
|
|
|
match = /(.*).done/.match df.sub(/.+\//, "")
|
|
|
|
meeting_id = match[1]
|
|
|
|
|
2012-08-22 05:55:41 +08:00
|
|
|
has_failed = sanity_failed_files.any? { |s| s.include?(meeting_id) }
|
|
|
|
if(has_failed)
|
|
|
|
BigBlueButton.logger.info("it has failed sanity check... skipping meeting: #{meeting_id}")
|
|
|
|
next
|
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
|
2012-08-22 05:55:41 +08:00
|
|
|
is_sanity_check_completed = sanity_done_files.any? { |s| s.include?(meeting_id) }
|
2012-08-21 07:12:58 +08:00
|
|
|
if(!is_sanity_check_completed)
|
|
|
|
command = "ruby sanity/sanity.rb -m #{meeting_id}"
|
|
|
|
BigBlueButton.execute(command)
|
|
|
|
end
|
2012-08-16 08:10:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-06-07 02:42:38 +08:00
|
|
|
def process_archived_meeting(recording_dir)
|
2012-08-21 07:12:58 +08:00
|
|
|
sanity_done_files = Dir.glob("#{recording_dir}/status/sanity/*.done")
|
2011-12-07 04:22:35 +08:00
|
|
|
|
2012-08-21 07:12:58 +08:00
|
|
|
sanity_done_files.each do |df|
|
2011-06-07 02:58:16 +08:00
|
|
|
match = /(.*).done/.match df.sub(/.+\//, "")
|
|
|
|
meeting_id = match[1]
|
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
# Execute all the scripts under the steps directory.
|
|
|
|
# This script must be invoked from the scripts directory for the PATH to be resolved.
|
|
|
|
Dir.glob("#{Dir.pwd}/process/*.rb").sort.each do |file|
|
2011-12-08 05:18:21 +08:00
|
|
|
|
|
|
|
# Checking if the meeting hasn't been processed
|
|
|
|
match2 = /(.*).rb/.match file.sub(/.+\//, "")
|
|
|
|
process_type = match2[1]
|
|
|
|
is_processed = false
|
|
|
|
if File.directory?("#{recording_dir}/process/#{process_type}")
|
|
|
|
processed_dirs = Dir.entries("#{recording_dir}/process/#{process_type}") - ['.','..']
|
|
|
|
is_processed = processed_dirs.any? { |s| s.include?(meeting_id) }
|
|
|
|
end
|
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
if(!is_processed)
|
|
|
|
# BigBlueButton.logger.info("Executing #{file}\n")
|
|
|
|
#IO.popen("ruby #{file} -m #{meeting_id}")
|
|
|
|
#Process.wait
|
|
|
|
#puts "********** #{$?.exitstatus} #{$?.exited?} #{$?.success?}********************"
|
2011-12-08 05:18:21 +08:00
|
|
|
command = "ruby #{file} -m #{meeting_id}"
|
2013-06-14 04:13:20 +08:00
|
|
|
timestamp_start = Time.now
|
2011-12-07 04:22:35 +08:00
|
|
|
BigBlueButton.execute(command)
|
2013-06-14 04:13:20 +08:00
|
|
|
timestamp_stop = Time.now
|
|
|
|
processing_time = ((timestamp_stop-timestamp_start).to_f * 1000).truncate
|
|
|
|
processing_time_file = "#{recording_dir}/process/#{process_type}/#{meeting_id}/processing_time"
|
|
|
|
File.open(processing_time_file, 'w') { |file| file.write("#{processing_time}") }
|
2011-12-07 04:22:35 +08:00
|
|
|
end
|
2011-06-30 06:39:25 +08:00
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
end
|
2011-06-07 02:58:16 +08:00
|
|
|
end
|
2011-05-14 05:45:59 +08:00
|
|
|
end
|
|
|
|
|
2011-06-07 02:42:38 +08:00
|
|
|
def publish_processed_meeting(recording_dir)
|
2011-12-07 04:22:35 +08:00
|
|
|
processed_done_files = Dir.glob("#{recording_dir}/status/processed/*.done")
|
2011-12-08 05:18:21 +08:00
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
processed_done_files.each do |df|
|
2011-06-07 02:58:16 +08:00
|
|
|
match = /(.*).done/.match df.sub(/.+\//, "")
|
|
|
|
meeting_id = match[1]
|
|
|
|
|
|
|
|
# Execute all the scripts under the steps directory.
|
|
|
|
# This script must be invoked from the scripts directory for the PATH to be resolved.
|
|
|
|
Dir.glob("#{Dir.pwd}/publish/*.rb").sort.each do |file|
|
2011-12-07 04:22:35 +08:00
|
|
|
|
2011-12-08 05:18:21 +08:00
|
|
|
# Checking if the meeting hasn't been processed
|
|
|
|
match2 = /(.*).rb/.match file.sub(/.+\//, "")
|
|
|
|
publish_type = match2[1]
|
|
|
|
|
|
|
|
match2 = /(.*)-(.*)/.match meeting_id
|
|
|
|
c_meeting_id = match2[1]
|
|
|
|
|
|
|
|
is_published = false
|
|
|
|
if File.directory?("#{recording_dir}/publish/#{publish_type}")
|
|
|
|
published_dirs = Dir.entries("#{recording_dir}/publish/#{publish_type}") - ['.','..']
|
|
|
|
is_published = published_dirs.any? { |s| s.include?(c_meeting_id) }
|
|
|
|
end
|
|
|
|
|
2011-12-07 04:22:35 +08:00
|
|
|
if(!is_published)
|
|
|
|
# BigBlueButton.logger.info("Executing #{file}\n")
|
|
|
|
#IO.popen("ruby #{file} -m #{meeting_id}")
|
|
|
|
#Process.wait
|
|
|
|
#puts "********** #{$?.exitstatus} #{$?.exited?} #{$?.success?}********************"
|
|
|
|
command = "ruby #{file} -m #{meeting_id}"
|
|
|
|
BigBlueButton.execute(command)
|
|
|
|
end
|
2011-06-30 06:39:25 +08:00
|
|
|
|
2011-06-07 02:58:16 +08:00
|
|
|
end
|
|
|
|
end
|
2011-06-07 02:42:38 +08:00
|
|
|
end
|
|
|
|
|
2011-05-14 05:45:59 +08:00
|
|
|
props = YAML::load(File.open('bigbluebutton.yml'))
|
|
|
|
recording_dir = props['recording_dir']
|
2011-12-07 04:22:35 +08:00
|
|
|
archive_recorded_meeting(recording_dir)
|
2012-08-21 07:12:58 +08:00
|
|
|
sanity_archived_meeting(recording_dir)
|
2011-06-07 02:42:38 +08:00
|
|
|
process_archived_meeting(recording_dir)
|
2011-06-07 04:09:53 +08:00
|
|
|
publish_processed_meeting(recording_dir)
|
2011-05-14 05:45:59 +08:00
|
|
|
|