supervisor meta logs

This commit is contained in:
Aleksis Brezas 2014-10-06 10:46:46 +03:00 committed by Pablo Carranza Vélez
parent 5cf8e2c180
commit df2066e4de

View File

@ -31,17 +31,19 @@ publish = do ->
channel = "device-#{uuid}-logs" channel = "device-#{uuid}-logs"
# Redefine original function # Redefine original function
publish = (message) -> publish = (message, isMeta=false) ->
# Stop pubnub logging loads of "Missing Message" errors, as they are quite distracting pubnub.publish({ channel, message, isMeta })
message or= ' '
pubnub.publish({ channel, message })
# Replay queue now that we have initialised the publish function # Replay queue now that we have initialised the publish function
publish(args...) for args in publishQueue publish(args...) for args in publishQueue
return -> publishQueue.push(arguments) return -> publishQueue.push(arguments)
exports.kill = kill = (app) -> exports.logSupervisorEvent = logSupervisorEvent = (message) ->
publish(message, true)
exports.kill = kill = (app) ->
logSupervisorEvent( 'Killing application ' + app.imageId )
utils.mixpanelTrack('Application kill', app) utils.mixpanelTrack('Application kill', app)
updateDeviceInfo(status: 'Stopping') updateDeviceInfo(status: 'Stopping')
container = docker.getContainer(app.containerId) container = docker.getContainer(app.containerId)
@ -99,6 +101,7 @@ exports.start = start = (app) ->
docker.getImage(app.imageId).inspectAsync() docker.getImage(app.imageId).inspectAsync()
.catch (error) -> .catch (error) ->
utils.mixpanelTrack('Application install', app) utils.mixpanelTrack('Application install', app)
logSupervisorEvent('Installing application ' + app.imageId)
updateDeviceInfo(status: 'Downloading') updateDeviceInfo(status: 'Downloading')
docker.createImageAsync(fromImage: app.imageId) docker.createImageAsync(fromImage: app.imageId)
.then (stream) -> .then (stream) ->
@ -165,6 +168,7 @@ exports.start = start = (app) ->
) )
.tap -> .tap ->
utils.mixpanelTrack('Application start', app.imageId) utils.mixpanelTrack('Application start', app.imageId)
logSupervisorEvent('Starting application ' + app.imageId)
.finally -> .finally ->
updateDeviceInfo(status: 'Idle') updateDeviceInfo(status: 'Idle')
@ -254,6 +258,7 @@ exports.update = update = ->
localApp = apps[imageId] localApp = apps[imageId]
app = remoteApps[imageId] app = remoteApps[imageId]
utils.mixpanelTrack('Application update', app) utils.mixpanelTrack('Application update', app)
logSupervisorEvent('Updating application')
kill(localApp) kill(localApp)
.then -> .then ->
start(app) start(app)