2014-05-02 05:42:15 +08:00
|
|
|
bunyan = require 'bunyan'
|
|
|
|
chokidar = require 'chokidar'
|
|
|
|
Hapi = require 'hapi'
|
|
|
|
redis = require 'redis'
|
2014-05-01 23:30:09 +08:00
|
|
|
|
2014-05-02 21:50:46 +08:00
|
|
|
log = require './lib/logger'
|
2014-05-02 05:42:15 +08:00
|
|
|
pack = require './package'
|
|
|
|
routes = require './lib/routes'
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server = Hapi.createServer("0.0.0.0",
|
|
|
|
parseInt(process.env.PORT, 10) or 4000)
|
2014-05-01 23:30:09 +08:00
|
|
|
|
|
|
|
server.start(() ->
|
2014-05-02 05:42:15 +08:00
|
|
|
log.info(['start'], pack.name + ' - web interface: ' + server.info.uri)
|
2014-05-01 23:30:09 +08:00
|
|
|
)
|
|
|
|
|
2014-05-02 05:42:15 +08:00
|
|
|
server.route(routes.routes)
|