reverted back the previous implementation of presentation_export as process/publish scripts instead of just one publish script; now rap-worker cleans the workspace when the presentation format is published, so presentation dependet formats can execute in the next run

This commit is contained in:
Felipe Cecagno 2015-02-02 14:06:20 -02:00
parent d1bcfe9189
commit ad25125b19
4 changed files with 229 additions and 153 deletions

View File

@ -268,6 +268,24 @@ def publish_processed_meeting(recording_dir)
end
end
def clean_presentation_dependents(recording_dir)
# clean workspace so the formats that depend on the presentation format to be
# published will run
[ "presentation_export" ].each do |dependent_format|
presentation_published_done_files = Dir.glob("#{recording_dir}/status/published/*-presentation.done")
presentation_published_done_files.each do |published_done|
match = /([^\/]*)-([^\/-]*).done$/.match(published_done)
meeting_id = match[1]
process_type = match[2]
processed_fail = "#{recording_dir}/status/processed/#{meeting_id}-#{dependent_format}.fail"
if File.exists? processed_fail
BigBlueButton.logger.info "Removing #{processed_fail} so #{dependent_format} can execute in the next run of rap-worker"
FileUtils.rm processed_fail
end
end
end
end
def post_archive(meeting_id)
Dir.glob("post_archive/*.rb").sort.each do |post_archive_script|
match = /([^\/]*).rb$/.match(post_archive_script)
@ -362,6 +380,7 @@ begin
sanity_archived_meeting(recording_dir)
process_archived_meeting(recording_dir)
publish_processed_meeting(recording_dir)
clean_presentation_dependents(recording_dir)
BigBlueButton.logger.debug("rap-worker done")

View File

@ -1,153 +0,0 @@
# Set encoding to utf-8
# 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/>.
#
require File.expand_path('../../../lib/recordandplayback', __FILE__)
require 'rubygems'
require 'trollop'
require 'yaml'
require 'zip'
opts = Trollop::options do
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
end
meeting_id = opts[:meeting_id]
BigBlueButton.logger = Logger.new("/var/log/bigbluebutton/presentation_export/post_publish-#{meeting_id}.log", 'daily' )
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
recording_dir = bbb_props['recording_dir']
raw_archive_dir = "#{recording_dir}/raw/#{meeting_id}"
playback_host = bbb_props['playback_host']
props = YAML::load(File.open('presentation_export.yml'))
presentation_published_dir = props['presentation_published_dir']
presentation_unpublished_dir = props['presentation_unpublished_dir']
playback_dir = props['playback_dir']
published_dir = props['publish_dir']
publish_done = "#{recording_dir}/status/published/#{meeting_id}-presentation_export.done"
if not FileTest.directory? publish_done
############################
# this is the process part #
############################
process_dir = "#{recording_dir}/process/presentation_export/#{meeting_id}"
FileUtils.rm_rf process_dir
FileUtils.mkdir_p process_dir
presentation_done = "#{recording_dir}/status/published/#{meeting_id}-presentation.done"
if not File.exists? presentation_done
BigBlueButton.logger.warn "Presentation format seems not to be published, aborting"
abort
end
meeting_published_dir = nil
[ "#{presentation_published_dir}/#{meeting_id}",
"#{presentation_unpublished_dir}/#{meeting_id}" ].each do |dir|
if FileTest.directory? dir
meeting_published_dir = dir
break
end
end
if not meeting_published_dir
BigBlueButton.logger.warn "Couldn't locate the presentation published/unpublished files, aborting"
abort
end
BigBlueButton.logger.info("Processing script presentation_export.rb")
resources_dir = "#{process_dir}/resources"
FileUtils.mkdir_p resources_dir
FileUtils.cp_r Dir.glob("#{meeting_published_dir}/*"), resources_dir
player_dir = "#{process_dir}/playback"
FileUtils.mkdir_p player_dir
FileUtils.cp_r Dir.glob("#{playback_dir}/*"), player_dir
############################
# this is the publish part #
############################
publish_dir = "#{recording_dir}/publish/presentation_export/#{meeting_id}"
BigBlueButton.logger.info("Making dir publish_dir")
FileUtils.rm_rf publish_dir
FileUtils.mkdir_p publish_dir
temp_dir = "#{publish_dir}/temp"
FileUtils.mkdir_p temp_dir
zipped_directory = "#{temp_dir}/zipped"
FileUtils.mkdir_p zipped_directory
FileUtils.cp_r "#{process_dir}/resources", zipped_directory
FileUtils.cp_r "#{process_dir}/playback", zipped_directory
FileUtils.mv "#{zipped_directory}/playback/playback.html", zipped_directory
package_dir = "#{publish_dir}/#{meeting_id}"
BigBlueButton.logger.info("Making dir package_dir")
FileUtils.mkdir_p package_dir
BigBlueButton.logger.info("Creating the .zip file")
zipped_file = "#{package_dir}/#{meeting_id}.zip"
Zip::File.open(zipped_file, Zip::File::CREATE) do |zipfile|
Dir["#{zipped_directory}/**/**"].reject{|f|f==zipped_file}.each do |file|
zipfile.add(file.sub(zipped_directory+'/', ''), file)
end
end
FileUtils.chmod 0644, zipped_file
BigBlueButton.logger.info("Creating metadata.xml")
presentation_metadata = "#{meeting_published_dir}/metadata.xml"
BigBlueButton.logger.info "Parsing metadata on #{presentation_metadata}"
doc = nil
begin
doc = Nokogiri::XML(open(presentation_metadata).read)
rescue Exception => e
BigBlueButton.logger.error "Something went wrong: #{$!}"
raise e
end
doc.at("published").content = true;
doc.at("format").content = "presentation_export"
doc.at("link").content = "http://#{playback_host}/presentation_export/#{meeting_id}/#{meeting_id}.zip"
metadata_xml = File.new("#{package_dir}/metadata.xml","w")
metadata_xml.write(doc.to_xml(:indent => 2))
metadata_xml.close
if not FileTest.directory?(published_dir)
FileUtils.mkdir_p published_dir
end
FileUtils.cp_r(package_dir, published_dir) # Copy all the files.
BigBlueButton.logger.info("Finished publishing script presentation.rb successfully.")
BigBlueButton.logger.info("Removing processed files.")
FileUtils.rm_r(process_dir)
BigBlueButton.logger.info("Removing published files.")
FileUtils.rm_r(publish_dir)
FileUtils.touch("#{recording_dir}/status/published/#{meeting_id}-presentation_export.done")
end

View File

@ -0,0 +1,87 @@
# Set encoding to utf-8
# 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/>.
#
require File.expand_path('../../../lib/recordandplayback', __FILE__)
require 'rubygems'
require 'trollop'
require 'yaml'
opts = Trollop::options do
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
end
meeting_id = opts[:meeting_id]
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
recording_dir = bbb_props['recording_dir']
props = YAML::load(File.open('presentation_export.yml'))
presentation_published_dir = props['presentation_published_dir']
presentation_unpublished_dir = props['presentation_unpublished_dir']
playback_dir = props['playback_dir']
target_dir = "#{recording_dir}/process/presentation_export/#{meeting_id}"
if not FileTest.directory?(target_dir)
# this recording has never been processed
logger = Logger.new("/var/log/bigbluebutton/presentation_export/process-#{meeting_id}.log", 'daily' )
BigBlueButton.logger = logger
if not File.exists? "#{recording_dir}/status/published/#{meeting_id}-presentation.done"
BigBlueButton.logger.info "Presentation not published yet, aborting"
abort
end
FileUtils.mkdir_p "/var/log/bigbluebutton/presentation_export"
publish_dir = "#{recording_dir}/publish/presentation/#{meeting_id}"
if FileTest.directory?(publish_dir)
# this recording has already been published (or publish processed), need to
# figure out if it's published or unpublished
meeting_published_dir = "#{presentation_published_dir}/#{meeting_id}"
if not FileTest.directory?(meeting_published_dir)
meeting_published_dir = "#{presentation_unpublished_dir}/#{meeting_id}"
if not FileTest.directory?(meeting_published_dir)
meeting_published_dir = nil
end
end
if meeting_published_dir
BigBlueButton.logger.info("Processing script presentation_export.rb")
FileUtils.mkdir_p target_dir
resources_dir = "#{target_dir}/resources"
FileUtils.mkdir_p resources_dir
FileUtils.cp_r Dir.glob("#{meeting_published_dir}/*"), resources_dir
player_dir = "#{target_dir}/playback"
FileUtils.mkdir_p player_dir
FileUtils.cp_r Dir.glob("#{playback_dir}/*"), player_dir
process_done = File.new("#{recording_dir}/status/processed/#{meeting_id}-presentation_export.done", "w")
process_done.write("Processed #{meeting_id}")
process_done.close
end
end
end

View File

@ -0,0 +1,123 @@
# Set encoding to utf-8
# 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/>.
#
require File.expand_path('../../../lib/recordandplayback', __FILE__)
require 'rubygems'
require 'trollop'
require 'yaml'
require 'zip'
opts = Trollop::options do
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
end
$meeting_id = opts[:meeting_id]
match = /(.*)-(.*)/.match $meeting_id
$meeting_id = match[1]
$playback = match[2]
if ($playback == "presentation_export")
logger = Logger.new("/var/log/bigbluebutton/presentation_export/publish-#{$meeting_id}.log", 'daily' )
BigBlueButton.logger = logger
# This script lives in scripts/archive/steps while properties.yaml lives in scripts/
bbb_props = YAML::load(File.open('../../core/scripts/bigbluebutton.yml'))
simple_props = YAML::load(File.open('presentation_export.yml'))
BigBlueButton.logger.info("Setting recording dir")
recording_dir = bbb_props['recording_dir']
BigBlueButton.logger.info("Setting process dir")
process_dir = "#{recording_dir}/process/presentation_export/#{$meeting_id}"
BigBlueButton.logger.info("setting publish dir")
publish_dir = simple_props['publish_dir']
BigBlueButton.logger.info("setting playback host")
playback_host = bbb_props['playback_host']
BigBlueButton.logger.info("setting target dir")
target_dir = "#{recording_dir}/publish/presentation_export/#{$meeting_id}"
raw_archive_dir = "#{recording_dir}/raw/#{$meeting_id}"
if not FileTest.directory?(target_dir)
if not File.exists? "#{recording_dir}/status/published/#{$meeting_id}-presentation.done"
BigBlueButton.logger.info "Presentation not published yet, aborting"
abort
end
BigBlueButton.logger.info("Making dir target_dir")
FileUtils.mkdir_p target_dir
temp_dir = "#{target_dir}/temp"
FileUtils.mkdir_p temp_dir
zipped_directory = "#{temp_dir}/zipped"
FileUtils.mkdir_p zipped_directory
FileUtils.cp_r "#{process_dir}/resources", zipped_directory
FileUtils.cp_r "#{process_dir}/playback", zipped_directory
FileUtils.mv "#{zipped_directory}/playback/playback.html", zipped_directory
package_dir = "#{target_dir}/#{$meeting_id}"
BigBlueButton.logger.info("Making dir package_dir")
FileUtils.mkdir_p package_dir
BigBlueButton.logger.info("Creating the .zip file")
zipped_file = "#{package_dir}/#{$meeting_id}.zip"
Zip::File.open(zipped_file, Zip::File::CREATE) do |zipfile|
Dir["#{zipped_directory}/**/**"].reject{|f|f==zipped_file}.each do |file|
zipfile.add(file.sub(zipped_directory+'/', ''), file)
end
end
BigBlueButton.logger.info("Creating metadata.xml")
presentation_metadata = "#{process_dir}/resources/metadata.xml"
BigBlueButton.logger.info "Parsing metadata on #{presentation_metadata}"
doc = nil
begin
doc = Nokogiri::XML(open(presentation_metadata).read)
rescue Exception => e
BigBlueButton.logger.error "Something went wrong: #{$!}"
raise e
end
doc.at("published").content = true;
doc.at("format").content = "presentation_export"
doc.at("link").content = "http://#{playback_host}/presentation_export/#{$meeting_id}/#{$meeting_id}.zip"
metadata_xml = File.new("#{package_dir}/metadata.xml","w")
metadata_xml.write(doc.to_xml(:indent => 2))
metadata_xml.close
if not FileTest.directory?(publish_dir)
FileUtils.mkdir_p publish_dir
end
FileUtils.cp_r(package_dir, publish_dir) # Copy all the files.
BigBlueButton.logger.info("Finished publishing script presentation.rb successfully.")
BigBlueButton.logger.info("Removing processed files.")
FileUtils.rm_r(Dir.glob("#{process_dir}/*"))
BigBlueButton.logger.info("Removing published files.")
FileUtils.rm_r(Dir.glob("#{target_dir}/*"))
publish_done = File.new("#{recording_dir}/status/published/#{$meeting_id}-presentation_export.done", "w")
publish_done.write("Published #{$meeting_id}")
publish_done.close
end
end