Add new reboot option and restart lamassu-browser

This commit is contained in:
Rafael Taranto 2019-07-16 12:00:16 +01:00 committed by Josh Harvey
parent 371454b6d4
commit 9f8693a33e
6 changed files with 89 additions and 5 deletions

View file

@ -29,6 +29,7 @@ const REQUEST_TTL = 3 * 60 * 1000
const pids = {}
const reboots = {}
const restartServicesMap = {}
const devMode = argv.dev || options.http
@ -53,6 +54,7 @@ function poll (req, res, next) {
const cassettes = results.cassettes
const reboot = pid && reboots[deviceId] && reboots[deviceId] === pid
const restartServices = pid && restartServicesMap[deviceId] && restartServicesMap[deviceId] === pid
const langs = config.machineLanguages
const locale = {
@ -90,6 +92,7 @@ function poll (req, res, next) {
twoWayMode: config.cashOutEnabled,
zeroConfLimit: config.zeroConfLimit,
reboot,
restartServices,
hasLightning,
operatorInfo: {
active: config.operatorInfoActive,
@ -399,6 +402,18 @@ localApp.post('/reboot', (req, res) => {
res.sendStatus(200)
})
localApp.post('/restartServices', (req, res) => {
const deviceId = req.query.device_id
const pid = pids[deviceId] && pids[deviceId].pid
if (!deviceId || !pid) {
return res.sendStatus(400)
}
restartServicesMap[deviceId] = pid
res.sendStatus(200)
})
localApp.post('/dbChange', (req, res, next) => {
return settingsLoader.loadLatest()
.then(poller.reload)