Skip to content

Commit 2166a38

Browse files
rcourtmanclaude
andcommitted
fix: support non-sequential server IDs in configuration
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 <noreply@anthropic.com>
1 parent 52a292b commit 2166a38

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

server/configLoader.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,17 @@ function loadConfiguration() {
206206
}
207207

208208
// Load additional Proxmox endpoints
209-
let i = 2;
210-
while (process.env[`PROXMOX_HOST_${i}`]) {
209+
// Check all environment variables for PROXMOX_HOST_N pattern to handle non-sequential numbering
210+
const proxmoxHostKeys = Object.keys(process.env)
211+
.filter(key => key.match(/^PROXMOX_HOST_\d+$/))
212+
.map(key => {
213+
const match = key.match(/^PROXMOX_HOST_(\d+)$/);
214+
return match ? parseInt(match[1]) : null;
215+
})
216+
.filter(num => num !== null)
217+
.sort((a, b) => a - b);
218+
219+
for (const i of proxmoxHostKeys) {
211220
const additionalEndpoint = createProxmoxEndpointConfig(
212221
'endpoint',
213222
i,
@@ -222,7 +231,6 @@ function loadConfiguration() {
222231
if (additionalEndpoint) {
223232
endpoints.push(additionalEndpoint);
224233
}
225-
i++;
226234
}
227235

228236
if (endpoints.length > 1) {
@@ -239,14 +247,21 @@ function loadConfiguration() {
239247
}
240248

241249
// Load additional PBS configs
242-
let pbsIndex = 2;
243-
let pbsResult = loadPbsConfig(pbsIndex);
244-
while (pbsResult.found) { // Continue as long as a PBS_HOST_n was found
250+
// Check all environment variables for PBS_HOST_N pattern to handle non-sequential numbering
251+
const pbsHostKeys = Object.keys(process.env)
252+
.filter(key => key.match(/^PBS_HOST_\d+$/))
253+
.map(key => {
254+
const match = key.match(/^PBS_HOST_(\d+)$/);
255+
return match ? parseInt(match[1]) : null;
256+
})
257+
.filter(num => num !== null)
258+
.sort((a, b) => a - b);
259+
260+
for (const pbsIndex of pbsHostKeys) {
261+
const pbsResult = loadPbsConfig(pbsIndex);
245262
if (pbsResult.config) {
246263
pbsConfigs.push(pbsResult.config);
247264
}
248-
pbsIndex++;
249-
pbsResult = loadPbsConfig(pbsIndex);
250265
}
251266

252267
if (pbsConfigs.length > 0) {

0 commit comments

Comments
 (0)