@@ -64,12 +64,8 @@ class ConfigApi {
64
64
*/
65
65
async saveConfig ( config ) {
66
66
try {
67
- console . log ( '[ConfigApi.saveConfig] Called with:' , JSON . stringify ( config , null , 2 ) ) ;
68
- console . log ( '[ConfigApi.saveConfig] .env path:' , this . envPath ) ;
69
-
70
67
// Read existing .env file to preserve other settings
71
68
const existingConfig = await this . readEnvFile ( ) ;
72
- console . log ( '[ConfigApi.saveConfig] Existing config keys:' , Object . keys ( existingConfig ) ) ;
73
69
74
70
// Handle both old structured format and new raw .env variable format
75
71
if ( config . proxmox || config . pbs || config . advanced ) {
@@ -81,14 +77,10 @@ class ConfigApi {
81
77
}
82
78
83
79
// Write back to .env file
84
- console . log ( '[ConfigApi.saveConfig] Writing config with keys:' , Object . keys ( existingConfig ) ) ;
85
80
await this . writeEnvFile ( existingConfig ) ;
86
- console . log ( '[ConfigApi.saveConfig] .env file written successfully' ) ;
87
81
88
82
// Reload configuration in the application
89
- console . log ( '[ConfigApi.saveConfig] Reloading configuration...' ) ;
90
83
await this . reloadConfiguration ( ) ;
91
- console . log ( '[ConfigApi.saveConfig] Configuration reloaded successfully' ) ;
92
84
93
85
return { success : true } ;
94
86
} catch ( error ) {
@@ -103,7 +95,6 @@ class ConfigApi {
103
95
handleStructuredConfig ( config , existingConfig ) {
104
96
// Update with new values
105
97
if ( config . proxmox ) {
106
- console . log ( '[ConfigApi.saveConfig] Updating Proxmox config' ) ;
107
98
existingConfig . PROXMOX_HOST = config . proxmox . host ;
108
99
existingConfig . PROXMOX_PORT = config . proxmox . port || '8006' ;
109
100
existingConfig . PROXMOX_TOKEN_ID = config . proxmox . tokenId ;
@@ -115,8 +106,6 @@ class ConfigApi {
115
106
116
107
// Always allow self-signed certificates by default for Proxmox
117
108
existingConfig . PROXMOX_ALLOW_SELF_SIGNED_CERT = 'true' ;
118
- } else {
119
- console . log ( '[ConfigApi.saveConfig] No Proxmox config provided' ) ;
120
109
}
121
110
122
111
if ( config . pbs ) {
@@ -173,12 +162,9 @@ class ConfigApi {
173
162
* Handle raw .env variable format (new settings form)
174
163
*/
175
164
handleRawEnvConfig ( config , existingConfig ) {
176
- console . log ( '[ConfigApi.saveConfig] Processing raw .env variable format' ) ;
177
-
178
165
// Directly update existing config with new values
179
166
Object . entries ( config ) . forEach ( ( [ key , value ] ) => {
180
167
if ( value !== undefined && value !== '' ) {
181
- console . log ( `[ConfigApi.saveConfig] Setting ${ key } = ${ value } ` ) ;
182
168
existingConfig [ key ] = value ;
183
169
}
184
170
} ) ;
@@ -207,7 +193,6 @@ class ConfigApi {
207
193
*/
208
194
async testConfig ( config ) {
209
195
try {
210
- console . log ( '[ConfigApi.testConfig] Testing config:' , JSON . stringify ( config , null , 2 ) ) ;
211
196
212
197
// Handle both old structured format and new raw .env format
213
198
let proxmoxHost , proxmoxPort , proxmoxTokenId , proxmoxTokenSecret ;
@@ -312,7 +297,6 @@ class ConfigApi {
312
297
await testClient . client . get ( '/nodes' ) ;
313
298
}
314
299
315
- console . log ( '[ConfigApi.testConfig] Connection test successful' ) ;
316
300
return { success : true } ;
317
301
} catch ( error ) {
318
302
console . error ( 'Configuration test failed:' , error ) ;
@@ -412,7 +396,6 @@ class ConfigApi {
412
396
413
397
try {
414
398
await fs . writeFile ( this . envPath , lines . join ( '\n' ) , 'utf8' ) ;
415
- console . log ( `[ConfigApi.writeEnvFile] Successfully wrote ${ lines . length } lines to ${ this . envPath } ` ) ;
416
399
} catch ( writeError ) {
417
400
console . error ( '[ConfigApi.writeEnvFile] Error writing file:' , writeError ) ;
418
401
throw writeError ;
@@ -437,16 +420,8 @@ class ConfigApi {
437
420
// Reload environment variables
438
421
require ( 'dotenv' ) . config ( ) ;
439
422
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
-
446
423
// Reload configuration
447
424
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 } ) ) ) ;
450
425
451
426
// Get state manager instance
452
427
const stateManager = require ( './state' ) ;
@@ -456,10 +431,7 @@ class ConfigApi {
456
431
stateManager . setEndpointConfigurations ( endpoints , pbsConfigs ) ;
457
432
458
433
// Reinitialize API clients
459
- console . log ( '[ConfigApi.reloadConfiguration] Reinitializing API clients...' ) ;
460
434
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 ) ) ;
463
435
464
436
// Update global references
465
437
if ( global . pulseApiClients ) {
@@ -477,16 +449,6 @@ class ConfigApi {
477
449
global . lastReloadTime = Date . now ( ) ;
478
450
}
479
451
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
-
490
452
// Trigger a discovery cycle if we have endpoints configured
491
453
if ( endpoints . length > 0 ) {
492
454
console . log ( 'Triggering discovery cycle after configuration reload...' ) ;
@@ -523,9 +485,7 @@ class ConfigApi {
523
485
// Save configuration
524
486
app . post ( '/api/config' , async ( req , res ) => {
525
487
try {
526
- console . log ( '[API /api/config] POST received with body:' , JSON . stringify ( req . body , null , 2 ) ) ;
527
488
const result = await this . saveConfig ( req . body ) ;
528
- console . log ( '[API /api/config] Save result:' , result ) ;
529
489
res . json ( { success : true } ) ;
530
490
} catch ( error ) {
531
491
console . error ( '[API /api/config] Error:' , error ) ;
0 commit comments