2012-05-04 02:56:01 +08:00
|
|
|
# Set encoding to utf-8
|
|
|
|
# encoding: UTF-8
|
|
|
|
|
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}"
|
2011-12-07 04:22:35 +08:00
|
|
|
BigBlueButton.execute(command)
|
|
|
|
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
|
|
|
|