From f9d0cb5c36e54e6dc6af89a754c31a4dc2558bb8 Mon Sep 17 00:00:00 2001 From: siiky Date: Fri, 22 Nov 2024 11:11:18 +0000 Subject: [PATCH 1/4] fix: let Supervisor discover new services --- deploy/codebase/lamassu-machine-manager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/codebase/lamassu-machine-manager.js b/deploy/codebase/lamassu-machine-manager.js index 4cb41b3a4..b0ac20c91 100644 --- a/deploy/codebase/lamassu-machine-manager.js +++ b/deploy/codebase/lamassu-machine-manager.js @@ -144,7 +144,7 @@ const updateSystemd = cb => { function restartWatchdogService (cb) { async.series([ - async.apply(command, 'supervisorctl update lamassu-watchdog'), + async.apply(command, 'supervisorctl update'), async.apply(command, 'supervisorctl restart lamassu-watchdog'), ], err => { if (err) throw err; From e3965b7abd336384d280d5fd667fbead254aff86 Mon Sep 17 00:00:00 2001 From: siiky Date: Fri, 22 Nov 2024 11:13:14 +0000 Subject: [PATCH 2/4] fix: ensure GSR50 services are not running --- deploy/codebase/lamassu-machine-manager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/codebase/lamassu-machine-manager.js b/deploy/codebase/lamassu-machine-manager.js index b0ac20c91..2c83554a2 100644 --- a/deploy/codebase/lamassu-machine-manager.js +++ b/deploy/codebase/lamassu-machine-manager.js @@ -112,8 +112,8 @@ function updateSupervisor (cb) { commands.push(async.apply(command, `supervisorctl update ${services}`)) commands.push(async.apply(command, `supervisorctl stop ${services}`)) - if (machineCode == 'aveiro') { - LOG("Updating GSR50") + if (machineCode === 'aveiro') { + commands.push(async.apply(command, `supervisorctl stop lamassu-gsr50-devstart lamassu-gsr50`)) commands.push(async.apply(command, `cp ${applicationParentFolder}/lamassu-machine/lib/gsr50/binaries/* /opt/FujitsuGSR50/`)) commands.push(async.apply(command, `chmod +x /opt/FujitsuGSR50/FujitsuGSR50`)) } From e33dae756695c1d8af85747e78a98020914b5d8f Mon Sep 17 00:00:00 2001 From: siiky Date: Fri, 22 Nov 2024 11:14:23 +0000 Subject: [PATCH 3/4] refactor: avoid pushing into array --- deploy/codebase/lamassu-machine-manager.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/deploy/codebase/lamassu-machine-manager.js b/deploy/codebase/lamassu-machine-manager.js index 2c83554a2..228a51c09 100644 --- a/deploy/codebase/lamassu-machine-manager.js +++ b/deploy/codebase/lamassu-machine-manager.js @@ -106,12 +106,11 @@ function updateSupervisor (cb) { const commands = [ async.apply(command, `cp ${supervisorPath}/* /etc/supervisor/conf.d/`), 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`) ] - commands.push(async.apply(command, `supervisorctl update ${services}`)) - commands.push(async.apply(command, `supervisorctl stop ${services}`)) - if (machineCode === 'aveiro') { commands.push(async.apply(command, `supervisorctl stop lamassu-gsr50-devstart lamassu-gsr50`)) commands.push(async.apply(command, `cp ${applicationParentFolder}/lamassu-machine/lib/gsr50/binaries/* /opt/FujitsuGSR50/`)) From 2c417d4ade4bbf641d4654c82bdd8711c455af61 Mon Sep 17 00:00:00 2001 From: siiky Date: Fri, 22 Nov 2024 11:19:33 +0000 Subject: [PATCH 4/4] fix: don't break after removing `calibrate-screen` service --- deploy/codebase/lamassu-machine-manager.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/deploy/codebase/lamassu-machine-manager.js b/deploy/codebase/lamassu-machine-manager.js index 228a51c09..dccc6f350 100644 --- a/deploy/codebase/lamassu-machine-manager.js +++ b/deploy/codebase/lamassu-machine-manager.js @@ -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 { @@ -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') { @@ -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;