Change rap-starter to run persistently and watch for file changes
Instead of being executed every 30s by systemd, it's now a service that's running all the time and will wait for .done files to start the processing of recordings.
This commit is contained in:
parent
d769849ad6
commit
53c3ed0d7d
@ -24,25 +24,21 @@ require 'rubygems'
|
|||||||
require 'yaml'
|
require 'yaml'
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'resque'
|
require 'resque'
|
||||||
|
require 'rb-inotify'
|
||||||
|
|
||||||
def archive_recorded_meetings(props)
|
def archive_recorded_meetings(done_file)
|
||||||
recording_dir = props['recording_dir']
|
|
||||||
recorded_done_files = Dir.glob("#{recording_dir}/status/recorded/*.done")
|
|
||||||
|
|
||||||
FileUtils.mkdir_p("#{recording_dir}/status/archived")
|
FileUtils.mkdir_p("#{recording_dir}/status/archived")
|
||||||
recorded_done_files.each do |recorded_done|
|
|
||||||
recorded_done_base = File.basename(recorded_done, '.done')
|
|
||||||
meeting_id = nil
|
meeting_id = nil
|
||||||
break_timestamp = nil
|
break_timestamp = nil
|
||||||
|
|
||||||
if match = /^([0-9a-f]+-[0-9]+)$/.match(recorded_done_base)
|
if match = /^([0-9a-f]+-[0-9]+)$/.match(done_file)
|
||||||
meeting_id = match[1]
|
meeting_id = match[1]
|
||||||
elsif match = /^([0-9a-f]+-[0-9]+)-([0-9]+)$/.match(recorded_done_base)
|
elsif match = /^([0-9a-f]+-[0-9]+)-([0-9]+)$/.match(done_file)
|
||||||
meeting_id = match[1]
|
meeting_id = match[1]
|
||||||
break_timestamp = match[2]
|
break_timestamp = match[2]
|
||||||
else
|
else
|
||||||
BigBlueButton.logger.warn("Recording done file for #{recorded_done_base} has invalid format")
|
BigBlueButton.logger.warn("Recording done file for #{done_file} has invalid format")
|
||||||
next
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
attrs = {
|
attrs = {
|
||||||
@ -51,9 +47,6 @@ def archive_recorded_meetings(props)
|
|||||||
}
|
}
|
||||||
BigBlueButton.logger.info("Enqueuing job to archive #{attrs.inspect}")
|
BigBlueButton.logger.info("Enqueuing job to archive #{attrs.inspect}")
|
||||||
Resque.enqueue(BigBlueButton::Resque::ArchiveWorker, attrs)
|
Resque.enqueue(BigBlueButton::Resque::ArchiveWorker, attrs)
|
||||||
|
|
||||||
FileUtils.rm_f(recorded_done)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -68,12 +61,23 @@ begin
|
|||||||
redis_port = props['redis_workers_port'] || props['redis_port']
|
redis_port = props['redis_workers_port'] || props['redis_port']
|
||||||
Resque.redis = "#{redis_host}:#{redis_port}"
|
Resque.redis = "#{redis_host}:#{redis_port}"
|
||||||
|
|
||||||
BigBlueButton.logger.debug('Running rap-trigger...')
|
logger.debug('Running rap-trigger...')
|
||||||
|
|
||||||
archive_recorded_meetings(props)
|
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')
|
||||||
|
|
||||||
BigBlueButton.logger.debug('rap-trigger done')
|
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
|
||||||
|
|
||||||
|
logger.info('Waiting for new recordings...')
|
||||||
|
notifier.run
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
BigBlueButton.logger.error(e.message)
|
BigBlueButton.logger.error(e.message)
|
||||||
e.backtrace.each do |traceline|
|
e.backtrace.each do |traceline|
|
||||||
|
@ -7,3 +7,4 @@ ExecStart=/usr/local/bigbluebutton/core/scripts/rap-starter.rb
|
|||||||
WorkingDirectory=/usr/local/bigbluebutton/core/scripts
|
WorkingDirectory=/usr/local/bigbluebutton/core/scripts
|
||||||
User=bigbluebutton
|
User=bigbluebutton
|
||||||
Slice=bbb_record_core.slice
|
Slice=bbb_record_core.slice
|
||||||
|
Restart=on-failure
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=BigBlueButton recording & playback processing
|
Description=BigBlueButton recording & playback processing
|
||||||
Wants=bbb-rap-starter-worker.service bbb-rap-events-worker.service
|
Wants=bbb-rap-events-worker.service
|
||||||
StopWhenUnneeded=true
|
StopWhenUnneeded=true
|
||||||
|
Loading…
Reference in New Issue
Block a user