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