From 273c9839e223998de69a488d5835845d97f39053 Mon Sep 17 00:00:00 2001 From: Cabecinha84 Date: Fri, 5 Jan 2024 18:24:39 +0000 Subject: [PATCH] if app is running in more instances than required after install is finish, uninstalls the app. --- ZelBack/src/services/appsService.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ZelBack/src/services/appsService.js b/ZelBack/src/services/appsService.js index 9b566800e..e7ec2bc90 100644 --- a/ZelBack/src/services/appsService.js +++ b/ZelBack/src/services/appsService.js @@ -8913,6 +8913,17 @@ async function trySpawningGlobalApplication() { return; } + // double check if app is installed in more of the instances requested + runningAppList = await getRunningAppList(appToRun); + minInstances = appSpecifications.instances || config.fluxapps.minimumInstances; // introduced in v3 of apps specs + if (runningAppList.length >= minInstances) { + log.info(`Application ${appToRun} is already spawned on ${runningAppList.length} instances, will unninstall it`); + removeAppLocally(appSpecifications.name, null, true, null, true).catch((error) => log.error(error)); + await serviceHelper.delay(10 * config.fluxapps.installation.delay * 1000); + trySpawningGlobalApplication(); + return; + } + await serviceHelper.delay(10 * config.fluxapps.installation.delay * 1000); log.info('Reinitiating possible app installation'); trySpawningGlobalApplication();