Skip to content

Commit

Permalink
if app is running in more instances than required after install is fi…
Browse files Browse the repository at this point in the history
…nish, uninstalls the app.
  • Loading branch information
Cabecinha84 committed Jan 5, 2024
1 parent c3c34cc commit 273c983
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ZelBack/src/services/appsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 273c983

Please sign in to comment.