mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-22 03:04:03 +00:00
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>
This commit is contained in:
+23
-8
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user