mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2025-04-19 00:26:53 +00:00
Add /v1/restart API endpoint
This commit is contained in:
parent
a15c9e636e
commit
d5ddad914e
@ -92,4 +92,22 @@ module.exports = (secret) ->
|
||||
utils.disableCheck(true)
|
||||
res.sendStatus(204)
|
||||
|
||||
api.post '/v1/restart', (req, res) ->
|
||||
appId = req.body.appId
|
||||
utils.mixpanelTrack('Restart container', appId)
|
||||
if !appId?
|
||||
return res.status(400).send('Missing app id')
|
||||
Promise.using application.lockUpdates(appId, true), ->
|
||||
knex('app').select().where({ appId })
|
||||
.then ([ app ]) ->
|
||||
if !app?
|
||||
throw new Error('App not found')
|
||||
application.kill(app)
|
||||
.then ->
|
||||
application.start(app)
|
||||
.then ->
|
||||
res.status(200).send('OK')
|
||||
.catch (err) ->
|
||||
res.status(503).send(err?.message or err or 'Unknown error')
|
||||
|
||||
return api
|
||||
|
Loading…
x
Reference in New Issue
Block a user