From 81c07e118ca1e862f322e8ba297c0074155255ec Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Sat, 31 May 2025 17:30:04 +0100 Subject: [PATCH] fix: support non-sequential server IDs in configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the config loader required sequential numbering (2, 3, 4...) for additional Proxmox/PBS endpoints. If a user had PROXMOX_HOST_2 and PROXMOX_HOST_4 (skipping 3), only endpoint 2 would be loaded. This fix scans all environment variables to find any PROXMOX_HOST_N or PBS_HOST_N patterns, regardless of numbering sequence. Now users can have endpoints numbered 2, 5, 10, etc. and all will be properly loaded. Fixes #96 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- server/configLoader.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/server/configLoader.js b/server/configLoader.js index 29d707e2d..af1b1e3ef 100644 --- a/server/configLoader.js +++ b/server/configLoader.js @@ -206,8 +206,17 @@ function loadConfiguration() { } // Load additional Proxmox endpoints - let i = 2; - while (process.env[`PROXMOX_HOST_${i}`]) { + // Check all environment variables for PROXMOX_HOST_N pattern to handle non-sequential numbering + const proxmoxHostKeys = Object.keys(process.env) + .filter(key => key.match(/^PROXMOX_HOST_\d+$/)) + .map(key => { + const match = key.match(/^PROXMOX_HOST_(\d+)$/); + return match ? parseInt(match[1]) : null; + }) + .filter(num => num !== null) + .sort((a, b) => a - b); + + for (const i of proxmoxHostKeys) { const additionalEndpoint = createProxmoxEndpointConfig( 'endpoint', i, @@ -222,7 +231,6 @@ function loadConfiguration() { if (additionalEndpoint) { endpoints.push(additionalEndpoint); } - i++; } if (endpoints.length > 1) { @@ -239,14 +247,21 @@ function loadConfiguration() { } // Load additional PBS configs - let pbsIndex = 2; - let pbsResult = loadPbsConfig(pbsIndex); - while (pbsResult.found) { // Continue as long as a PBS_HOST_n was found + // Check all environment variables for PBS_HOST_N pattern to handle non-sequential numbering + const pbsHostKeys = Object.keys(process.env) + .filter(key => key.match(/^PBS_HOST_\d+$/)) + .map(key => { + const match = key.match(/^PBS_HOST_(\d+)$/); + return match ? parseInt(match[1]) : null; + }) + .filter(num => num !== null) + .sort((a, b) => a - b); + + for (const pbsIndex of pbsHostKeys) { + const pbsResult = loadPbsConfig(pbsIndex); if (pbsResult.config) { pbsConfigs.push(pbsResult.config); } - pbsIndex++; - pbsResult = loadPbsConfig(pbsIndex); } if (pbsConfigs.length > 0) {