 			docker.getImage(app.imageId).inspectAsync()
 			.catch (error) ->
 				utils.mixpanelTrack('Application install', app)
+				logSupervisorEvent('Installing application ' + app.imageId)
 				updateDeviceInfo(status: 'Downloading')
 				docker.createImageAsync(fromImage: app.imageId)
 				.then (stream) ->

					localApp = apps[imageId]
					app = remoteApps[imageId]
					utils.mixpanelTrack('Application update', app)
					kill(localApp)
					.then ->
						start(app)

		channel = "device-#{uuid}-logs"

		# Redefine original function
		publish = (message, isMeta=false) ->
			pubnub.publish({ channel, message, isMeta })

		# Replay queue now that we have initialised the publish function
		publish(args...) for args in publishQueue

	return -> publishQueue.push(arguments)

exports.logSupervisorEvent = logSupervisorEvent = (message) ->
	publish(message, true)

exports.kill = kill = (app) ->	
	logSupervisorEvent( 'Killing application ' + app.imageId )
	utils.mixpanelTrack('Application kill', app)
	updateDeviceInfo(status: 'Stopping')
	container = docker.getContainer(app.containerId)
