Add success/failure messages for better user info when there are issues.

This commit is contained in:
Pagan Gazzard 2015-03-27 14:46:20 +00:00 committed by Pablo Carranza Vélez
parent 368a23b823
commit 98ae03cf67

View File

@ -27,6 +27,9 @@ logTypes =
stopAppSuccess: stopAppSuccess:
eventName: 'Application stop' eventName: 'Application stop'
humanName: 'Killed application' humanName: 'Killed application'
stopAppError:
eventName: 'Application stop error'
humanName: 'Killed application'
downloadApp: downloadApp:
eventName: 'Application download' eventName: 'Application download'
@ -34,10 +37,19 @@ logTypes =
downloadAppSuccess: downloadAppSuccess:
eventName: 'Application downloaded' eventName: 'Application downloaded'
humanName: 'Downloaded application' humanName: 'Downloaded application'
downloadAppError:
eventName: 'Application download error'
humanName: 'Failed to download application'
installApp: installApp:
eventName: 'Application install' eventName: 'Application install'
humanName: 'Installing application' humanName: 'Installing application'
installAppSuccess:
eventName: 'Application installed'
humanName: 'Installed application'
installAppError:
eventName: 'Application install error'
humanName: 'Failed to install application'
startApp: startApp:
eventName: 'Application start' eventName: 'Application start'
@ -91,6 +103,9 @@ kill = (app) ->
.tap -> .tap ->
logSystemEvent(logTypes.stopAppSuccess, app) logSystemEvent(logTypes.stopAppSuccess, app)
knex('app').where('id', app.id).delete() knex('app').where('id', app.id).delete()
.catch (err) ->
logSystemEvent(logTypes.stopAppError, app, err)
throw err
isValidPort = (port) -> isValidPort = (port) ->
maybePort = parseInt(port, 10) maybePort = parseInt(port, 10)
@ -107,6 +122,9 @@ fetch = (app) ->
logSystemEvent(logTypes.downloadAppSuccess, app) logSystemEvent(logTypes.downloadAppSuccess, app)
updateDeviceState(download_progress: null) updateDeviceState(download_progress: null)
docker.getImage(app.imageId).inspectAsync() docker.getImage(app.imageId).inspectAsync()
.catch (err) ->
logSystemEvent(logTypes.downloadAppError, app, err)
throw err
exports.start = start = (app) -> exports.start = start = (app) ->
Promise.try -> Promise.try ->
@ -154,6 +172,11 @@ exports.start = start = (app) ->
Env: _.map env, (v, k) -> k + '=' + v Env: _.map env, (v, k) -> k + '=' + v
ExposedPorts: ports ExposedPorts: ports
) )
.tap ->
logSystemEvent(logTypes.installAppSuccess, app)
.catch (err) ->
logSystemEvent(logTypes.installAppError, app, err)
throw err
.tap (container) -> .tap (container) ->
# Update the app info the moment we create the container, even if then starting the container fails. This # Update the app info the moment we create the container, even if then starting the container fails. This
# stops issues with constantly creating new containers for an image that fails to start. # stops issues with constantly creating new containers for an image that fails to start.