mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-19 05:37:53 +00:00
Add system logs for Shutdown, Reboot and Purge
This commit is contained in:
parent
a97342bf9c
commit
f385fe6bcc
@ -1,3 +1,5 @@
|
||||
* Add system logs for Shutdown, Reboot and Purge [Pablo]
|
||||
|
||||
# v2.3.0
|
||||
|
||||
* Implement delete-then-download update strategy [Pablo]
|
||||
|
@ -49,7 +49,7 @@ module.exports = (application) ->
|
||||
|
||||
unparsedRouter.post '/v1/reboot', (req, res) ->
|
||||
new Promise (resolve, reject) ->
|
||||
utils.mixpanelTrack('Reboot')
|
||||
application.logSystemMessage('Rebooting', {}, 'Reboot')
|
||||
utils.gosuper.post('/v1/reboot')
|
||||
.on('error', reject)
|
||||
.on('response', -> resolve())
|
||||
@ -59,7 +59,7 @@ module.exports = (application) ->
|
||||
|
||||
unparsedRouter.post '/v1/shutdown', (req, res) ->
|
||||
new Promise (resolve, reject) ->
|
||||
utils.mixpanelTrack('Shutdown')
|
||||
application.logSystemMessage('Shutting down', {}, 'Shutdown')
|
||||
utils.gosuper.post('/v1/shutdown')
|
||||
.on('error', reject)
|
||||
.on('response', -> resolve())
|
||||
@ -69,7 +69,7 @@ module.exports = (application) ->
|
||||
|
||||
parsedRouter.post '/v1/purge', (req, res) ->
|
||||
appId = req.body.appId
|
||||
utils.mixpanelTrack('Purge /data', appId)
|
||||
application.logSystemMessage('Purging /data', { appId }, 'Purge /data')
|
||||
if !appId?
|
||||
return res.status(400).send('Missing app id')
|
||||
Promise.using application.lockUpdates(appId, true), ->
|
||||
@ -82,8 +82,13 @@ module.exports = (application) ->
|
||||
.on('error', reject)
|
||||
.on('response', -> resolve())
|
||||
.pipe(res)
|
||||
.then ->
|
||||
application.logSystemMessage('Purged /data', { appId }, 'Purge /data success')
|
||||
.finally ->
|
||||
application.start(app)
|
||||
.catch (err) ->
|
||||
application.logSystemMessage("Error purging /data: #{err}", { appId, error: err }, 'Purge /data error')
|
||||
throw err
|
||||
.catch utils.AppNotFoundError, (e) ->
|
||||
return res.status(400).send(e.message)
|
||||
.catch (err) ->
|
||||
|
@ -91,7 +91,9 @@ logTypes =
|
||||
eventName: 'Application restart'
|
||||
humanName: 'Restarting application'
|
||||
|
||||
logSystemMessage = (message, obj, eventName) ->
|
||||
application = {}
|
||||
|
||||
application.logSystemMessage = logSystemMessage = (message, obj, eventName) ->
|
||||
logger.log({ m: message, s: 1 })
|
||||
utils.mixpanelTrack(eventName ? message, obj)
|
||||
|
||||
@ -117,8 +119,6 @@ logSpecialAction = (action, value, success) ->
|
||||
msg = "Applying config variable #{action} = #{value}"
|
||||
logSystemMessage(msg, {}, "Apply special action #{if success then "success" else "in progress"}")
|
||||
|
||||
application = {}
|
||||
|
||||
application.kill = kill = (app, updateDB = true, removeContainer = true) ->
|
||||
logSystemEvent(logTypes.stopApp, app)
|
||||
device.updateState(status: 'Stopping')
|
||||
|
Loading…
Reference in New Issue
Block a user