feat: make Supervisor logfile path configurable via environment variable
All checks were successful
Build and Push Docker Image to Gitea / build-and-push (push) Successful in 1m12s
All checks were successful
Build and Push Docker Image to Gitea / build-and-push (push) Successful in 1m12s
Added SUPERVISOR_LOGFILE environment variable to configure the path to the Supervisor main logfile for reading via XML-RPC. Changes: - Added SUPERVISOR_LOGFILE to .env.example with default path - Removed getLogfilePath() method and cachedLogfilePath field from SupervisorClient - Updated readLog() to use environment variable with fallback chain: 1. Explicitly provided logfilePath parameter 2. SUPERVISOR_LOGFILE environment variable 3. Default: /var/log/supervisor/supervisord.log - Added debug logging to readLog() for troubleshooting This allows users to configure the correct logfile path for their Supervisor installation when using the custom 3-parameter XML-RPC readLog implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,10 @@ SUPERVISOR_PORT=9001
|
|||||||
# SUPERVISOR_USERNAME=user
|
# SUPERVISOR_USERNAME=user
|
||||||
# SUPERVISOR_PASSWORD=pass
|
# SUPERVISOR_PASSWORD=pass
|
||||||
|
|
||||||
|
# Optional: Path to supervisord main logfile (for reading via XML-RPC)
|
||||||
|
# Default: /var/log/supervisor/supervisord.log
|
||||||
|
# SUPERVISOR_LOGFILE=/var/log/supervisor/supervisord.log
|
||||||
|
|
||||||
# Logging Configuration
|
# Logging Configuration
|
||||||
# Log level: debug, info, warn, error (default: info in prod, debug in dev)
|
# Log level: debug, info, warn, error (default: info in prod, debug in dev)
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ export class SupervisorClient {
|
|||||||
private client: xmlrpc.Client;
|
private client: xmlrpc.Client;
|
||||||
private config: SupervisorClientConfig;
|
private config: SupervisorClientConfig;
|
||||||
private logger: ReturnType<typeof createLogger>;
|
private logger: ReturnType<typeof createLogger>;
|
||||||
private cachedLogfilePath?: string;
|
|
||||||
|
|
||||||
constructor(config: SupervisorClientConfig) {
|
constructor(config: SupervisorClientConfig) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -102,40 +101,6 @@ export class SupervisorClient {
|
|||||||
return this.call<string>('supervisor.getSupervisorVersion');
|
return this.call<string>('supervisor.getSupervisorVersion');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get logfile path from API version metadata
|
|
||||||
* Caches the result after first call
|
|
||||||
*/
|
|
||||||
private async getLogfilePath(): Promise<string> {
|
|
||||||
if (this.cachedLogfilePath) {
|
|
||||||
return this.cachedLogfilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get API version which should contain logfile path in metadata
|
|
||||||
const apiVersionData = await this.call<any>('supervisor.getAPIVersion');
|
|
||||||
|
|
||||||
// Parse the response to extract logfile path
|
|
||||||
// The exact structure depends on your supervisor API implementation
|
|
||||||
// Common formats might be:
|
|
||||||
// - { version: "3.0", logfile: "/path/to/log" }
|
|
||||||
// - Just a string with embedded metadata
|
|
||||||
let logfilePath: string;
|
|
||||||
|
|
||||||
if (typeof apiVersionData === 'object' && apiVersionData.logfile) {
|
|
||||||
logfilePath = apiVersionData.logfile;
|
|
||||||
} else if (typeof apiVersionData === 'object' && apiVersionData.logfile_path) {
|
|
||||||
logfilePath = apiVersionData.logfile_path;
|
|
||||||
} else {
|
|
||||||
// Fallback to default supervisord log location if not found in metadata
|
|
||||||
this.logger.warn('Could not extract logfile path from getAPIVersion, using default');
|
|
||||||
logfilePath = '/var/log/supervisor/supervisord.log';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cachedLogfilePath = logfilePath;
|
|
||||||
this.logger.debug({ logfilePath }, 'Retrieved and cached logfile path');
|
|
||||||
return logfilePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getIdentification(): Promise<string> {
|
async getIdentification(): Promise<string> {
|
||||||
return this.call<string>('supervisor.getIdentification');
|
return this.call<string>('supervisor.getIdentification');
|
||||||
}
|
}
|
||||||
@@ -288,8 +253,9 @@ export class SupervisorClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async readLog(offset: number, length: number, logfilePath?: string): Promise<string> {
|
async readLog(offset: number, length: number, logfilePath?: string): Promise<string> {
|
||||||
// If logfilePath not provided, get it from API version metadata
|
// Use provided path, or fall back to env variable, or use default
|
||||||
const path = logfilePath || await this.getLogfilePath();
|
const path = logfilePath || process.env.SUPERVISOR_LOGFILE || '/var/log/supervisor/supervisord.log';
|
||||||
|
this.logger.debug({ path, offset, length }, 'Reading supervisor main log');
|
||||||
return this.call<string>('supervisor.readLog', [offset, length, path]);
|
return this.call<string>('supervisor.readLog', [offset, length, path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user