Skip to content

Commit

Permalink
fix: don't break after removing calibrate-screen service
Browse files Browse the repository at this point in the history
  • Loading branch information
siiky committed Nov 22, 2024
1 parent e33dae7 commit 2c417d4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions deploy/codebase/lamassu-machine-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ function updateSupervisor (cb) {
.split('\n')
.flatMap(line => {
const service = line.split(' ', 1)?.[0]
return (!service || service === 'lamassu-watchdog') ? [] : [service]
return service ? [service] : []
})
.join(' ')
.filter(service => service !== 'lamassu-watchdog')
/*
* NOTE: Keep old behavior in case we don't get the expected output:
* update and restart all services. result:finished won't work.
*/
return services.length > 0 ? services : 'all'
return services.length > 0 ? services : ['all']
}

try {
Expand All @@ -96,19 +96,21 @@ function updateSupervisor (cb) {
} catch (err) {
return err.status === 3 ?
extractServices(err.stdout) :
'all' /* NOTE: see note above */
['all'] /* NOTE: see note above */
}
}

const osuser = getOSUser()
const services = getServices()
const allServices = services.join(' ')
const servicesNoCalibrateScreen = services.filter(service => service !== 'calibrate-screen').join(' ')

const commands = [
async.apply(command, `cp ${supervisorPath}/* /etc/supervisor/conf.d/`),
async.apply(command, `sed -i 's|^user=.*\$|user=${osuser}|;' /etc/supervisor/conf.d/lamassu-browser.conf || true`),
async.apply(command, `rm -f /etc/supervisor/conf.d/calibrate-screen.conf`),
async.apply(command, `supervisorctl update ${services}`),
async.apply(command, `supervisorctl stop ${services}`),
async.apply(command, `sed -i 's|^user=.*\$|user=${osuser}|;' /etc/supervisor/conf.d/lamassu-browser.conf || true`)
async.apply(command, `supervisorctl update ${allServices}`),
async.apply(command, `supervisorctl stop ${servicesNoCalibrateScreen}`),
]

if (machineCode === 'aveiro') {
Expand All @@ -117,7 +119,7 @@ function updateSupervisor (cb) {
commands.push(async.apply(command, `chmod +x /opt/FujitsuGSR50/FujitsuGSR50`))
}

commands.push(async.apply(command, `supervisorctl restart ${services}`))
commands.push(async.apply(command, `supervisorctl restart ${servicesNoCalibrateScreen}`))

async.series(commands, err => {
if (err) throw err;
Expand Down

0 comments on commit 2c417d4

Please sign in to comment.