- put record watcher into module
This commit is contained in:
parent
0bb44609f1
commit
b0d4eea62e
@ -1,3 +1,5 @@
|
||||
# # Global configurations file
|
||||
|
||||
config = {}
|
||||
|
||||
# Logging
|
||||
|
46
labs/api/recordings/lib/recording-dir-watcher.coffee
Executable file
46
labs/api/recordings/lib/recording-dir-watcher.coffee
Executable file
@ -0,0 +1,46 @@
|
||||
##
|
||||
## Watches the recording dirs for new recordings
|
||||
##
|
||||
|
||||
chokidar = require 'chokidar'
|
||||
redis = require 'redis'
|
||||
|
||||
log = require './logger'
|
||||
|
||||
|
||||
client = redis.createClient()
|
||||
|
||||
baseKey = 'bbb:recordings:'
|
||||
|
||||
#clear the keys first
|
||||
keys = client.keys(baseKey.concat('*'))
|
||||
client.del(keys)
|
||||
|
||||
#start watching
|
||||
chokidar.watch('/var/bigbluebutton/published', {ignored: /[\/\\]\./}).on 'all', (event, path)->
|
||||
somethingChanged(event,path)
|
||||
chokidar.watch('/var/bigbluebutton/unpublished', {ignored: /[\/\\]\./}).on 'all', (event, path)->
|
||||
somethingChanged(event,path)
|
||||
|
||||
|
||||
somethingChanged = (event, path) ->
|
||||
uri = path.split('/')
|
||||
|
||||
if uri[5]? #excludes the parent directories being added
|
||||
#console.log "\nstart" + uri.toString()
|
||||
|
||||
meetingID = path.substring(path.lastIndexOf('/')+1).split('-')[0]
|
||||
timestamp = path.substring(path.lastIndexOf('/')+1).split('-')[1]
|
||||
|
||||
thisKey = baseKey.concat(meetingID)
|
||||
#console.log "thisKey=" + thisKey
|
||||
|
||||
json = {
|
||||
"format": uri[4]
|
||||
"timestamp": timestamp
|
||||
}
|
||||
|
||||
console.log(event, path)
|
||||
str = JSON.stringify(json)
|
||||
|
||||
client.sadd(thisKey, str)
|
Loading…
Reference in New Issue
Block a user