Skip to content

Commit

Permalink
make more readable that we only update haproxy after both g and non g…
Browse files Browse the repository at this point in the history
… process finish once
  • Loading branch information
Cabecinha84 committed Jul 30, 2024
1 parent eef584a commit c75c6b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/services/domainService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const mapOfNamesIps = {};
let recentlyConfiguredApps = null;
let recentlyConfiguredGApps = null;
let lastHaproxyAppsConfig = [];
let gAppsProcessingFinishedOnce = false;
let nonGAppsProcessingFinishedOnce = false;

async function getPermanentMessages() {
try {
Expand Down Expand Up @@ -606,17 +608,19 @@ async function generateAndReplaceMainApplicationHaproxyConfig(isGmode = false, t
let haproxyAppsConfig = [];
if (isGmode) {
recentlyConfiguredGApps = configuredApps;
if (recentlyConfiguredApps) {
gAppsProcessingFinishedOnce = true;
if (nonGAppsProcessingFinishedOnce) {
haproxyAppsConfig = recentlyConfiguredApps.concat(configuredApps);
}
} else {
recentlyConfiguredApps = configuredApps;
if (recentlyConfiguredGApps) {
nonGAppsProcessingFinishedOnce = true;
if (gAppsProcessingFinishedOnce) {
haproxyAppsConfig = configuredApps.concat(recentlyConfiguredGApps); // we need to put always in same order to avoid. non g first g at end
}
}

if (recentlyConfiguredGApps && recentlyConfiguredGApps && JSON.stringify(lastHaproxyAppsConfig) !== JSON.stringify(haproxyAppsConfig)) {
if (nonGAppsProcessingFinishedOnce && gAppsProcessingFinishedOnce && JSON.stringify(lastHaproxyAppsConfig) !== JSON.stringify(haproxyAppsConfig)) {
lastHaproxyAppsConfig = haproxyAppsConfig;
const hc = await haproxyTemplate.createAppsHaproxyConfig(haproxyAppsConfig);
console.log(hc);
Expand Down

0 comments on commit c75c6b7

Please sign in to comment.