@@ -427,11 +427,26 @@ class ConfigApi {
427
427
// Clear the require cache for dotenv
428
428
delete require . cache [ require . resolve ( 'dotenv' ) ] ;
429
429
430
+ // Clear all environment variables that might be cached
431
+ Object . keys ( process . env ) . forEach ( key => {
432
+ if ( key . startsWith ( 'PROXMOX_' ) || key . startsWith ( 'PBS_' ) || key . startsWith ( 'PULSE_' ) || key . startsWith ( 'ALERT_' ) ) {
433
+ delete process . env [ key ] ;
434
+ }
435
+ } ) ;
436
+
430
437
// Reload environment variables
431
438
require ( 'dotenv' ) . config ( ) ;
432
439
440
+ // Log environment variables for debugging
441
+ const envVars = Object . keys ( process . env ) . filter ( key =>
442
+ key . startsWith ( 'PROXMOX_' ) || key . startsWith ( 'PBS_' )
443
+ ) . sort ( ) ;
444
+ console . log ( '[ConfigApi.reloadConfiguration] Environment variables after reload:' , envVars ) ;
445
+
433
446
// Reload configuration
434
447
const { endpoints, pbsConfigs, isConfigPlaceholder } = loadConfiguration ( ) ;
448
+ console . log ( `[ConfigApi.reloadConfiguration] Loaded ${ endpoints . length } Proxmox endpoints:` , endpoints . map ( e => ( { id : e . id , name : e . name , host : e . host } ) ) ) ;
449
+ console . log ( `[ConfigApi.reloadConfiguration] Loaded ${ pbsConfigs . length } PBS configs:` , pbsConfigs . map ( p => ( { id : p . id , name : p . name , host : p . host } ) ) ) ;
435
450
436
451
// Get state manager instance
437
452
const stateManager = require ( './state' ) ;
@@ -441,7 +456,10 @@ class ConfigApi {
441
456
stateManager . setEndpointConfigurations ( endpoints , pbsConfigs ) ;
442
457
443
458
// Reinitialize API clients
459
+ console . log ( '[ConfigApi.reloadConfiguration] Reinitializing API clients...' ) ;
444
460
const { apiClients, pbsApiClients } = await initializeApiClients ( endpoints , pbsConfigs ) ;
461
+ console . log ( `[ConfigApi.reloadConfiguration] Initialized ${ Object . keys ( apiClients ) . length } API clients:` , Object . keys ( apiClients ) ) ;
462
+ console . log ( `[ConfigApi.reloadConfiguration] Initialized ${ Object . keys ( pbsApiClients ) . length } PBS clients:` , Object . keys ( pbsApiClients ) ) ;
445
463
446
464
// Update global references
447
465
if ( global . pulseApiClients ) {
@@ -459,6 +477,16 @@ class ConfigApi {
459
477
global . lastReloadTime = Date . now ( ) ;
460
478
}
461
479
480
+ // Manually verify additional endpoints are loaded
481
+ let additionalEndpointsFound = 0 ;
482
+ let i = 2 ;
483
+ while ( process . env [ `PROXMOX_HOST_${ i } ` ] ) {
484
+ console . log ( `[ConfigApi.reloadConfiguration] Found additional endpoint ${ i } : PROXMOX_HOST_${ i } =${ process . env [ `PROXMOX_HOST_${ i } ` ] } ` ) ;
485
+ additionalEndpointsFound ++ ;
486
+ i ++ ;
487
+ }
488
+ console . log ( `[ConfigApi.reloadConfiguration] Total additional endpoints found in environment: ${ additionalEndpointsFound } ` ) ;
489
+
462
490
// Trigger a discovery cycle if we have endpoints configured
463
491
if ( endpoints . length > 0 ) {
464
492
console . log ( 'Triggering discovery cycle after configuration reload...' ) ;
0 commit comments