feat(logging): add professional startup logging to DcRouter
- Add logStartupSummary() method with clean ASCII art header - Display service status for SmartProxy, Email, DNS, and Storage - Show detailed configuration info for each service - Replace verbose console logs with structured startup summary
This commit is contained in:
parent
272973702e
commit
fe817dde00
@ -146,7 +146,9 @@ export class DcRouter {
|
||||
}
|
||||
|
||||
public async start() {
|
||||
console.log('Starting DcRouter services...');
|
||||
console.log('╔═══════════════════════════════════════════════════════════════════╗');
|
||||
console.log('║ Starting DcRouter Services ║');
|
||||
console.log('╚═══════════════════════════════════════════════════════════════════╝');
|
||||
|
||||
try {
|
||||
// Set up SmartProxy for HTTP/HTTPS and all traffic including email routes
|
||||
@ -169,15 +171,82 @@ export class DcRouter {
|
||||
await this.setupDnsWithSocketHandler();
|
||||
}
|
||||
|
||||
console.log('DcRouter started successfully');
|
||||
this.logStartupSummary();
|
||||
} catch (error) {
|
||||
console.error('Error starting DcRouter:', error);
|
||||
console.error('❌ Error starting DcRouter:', error);
|
||||
// Try to clean up any services that may have started
|
||||
await this.stop();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log comprehensive startup summary
|
||||
*/
|
||||
private logStartupSummary(): void {
|
||||
console.log('\n╔═══════════════════════════════════════════════════════════════════╗');
|
||||
console.log('║ DcRouter Started Successfully ║');
|
||||
console.log('╚═══════════════════════════════════════════════════════════════════╝\n');
|
||||
|
||||
// SmartProxy summary
|
||||
if (this.smartProxy) {
|
||||
console.log('🌐 SmartProxy Service:');
|
||||
const routeCount = this.options.smartProxyConfig?.routes?.length || 0;
|
||||
console.log(` ├─ Routes configured: ${routeCount}`);
|
||||
console.log(` ├─ ACME enabled: ${this.options.smartProxyConfig?.acme?.enabled || false}`);
|
||||
if (this.options.smartProxyConfig?.acme?.enabled) {
|
||||
console.log(` ├─ ACME email: ${this.options.smartProxyConfig.acme.email || 'not set'}`);
|
||||
console.log(` └─ ACME mode: ${this.options.smartProxyConfig.acme.useProduction ? 'production' : 'staging'}`);
|
||||
} else {
|
||||
console.log(' └─ ACME: disabled');
|
||||
}
|
||||
}
|
||||
|
||||
// Email service summary
|
||||
if (this.emailServer && this.options.emailConfig) {
|
||||
console.log('\n📧 Email Service:');
|
||||
const ports = this.options.emailConfig.ports || [];
|
||||
console.log(` ├─ Ports: ${ports.join(', ')}`);
|
||||
console.log(` ├─ Hostname: ${this.options.emailConfig.hostname || 'localhost'}`);
|
||||
console.log(` ├─ Domains configured: ${this.options.emailConfig.domains?.length || 0}`);
|
||||
if (this.options.emailConfig.domains && this.options.emailConfig.domains.length > 0) {
|
||||
this.options.emailConfig.domains.forEach((domain, index) => {
|
||||
const isLast = index === this.options.emailConfig!.domains!.length - 1;
|
||||
console.log(` ${isLast ? '└─' : '├─'} ${domain.domain} (${domain.dnsMode || 'default'})`);
|
||||
});
|
||||
}
|
||||
console.log(` └─ DKIM: Initialized for all domains`);
|
||||
}
|
||||
|
||||
// DNS service summary
|
||||
if (this.dnsServer && this.options.dnsNsDomains && this.options.dnsScopes) {
|
||||
console.log('\n🌍 DNS Service:');
|
||||
console.log(` ├─ Nameservers: ${this.options.dnsNsDomains.join(', ')}`);
|
||||
console.log(` ├─ Primary NS: ${this.options.dnsNsDomains[0]}`);
|
||||
console.log(` ├─ Authoritative for: ${this.options.dnsScopes.length} domains`);
|
||||
console.log(` ├─ UDP Port: 53`);
|
||||
console.log(` ├─ DNS-over-HTTPS: Enabled via socket handler`);
|
||||
console.log(` └─ DNSSEC: ${this.options.dnsNsDomains[0] ? 'Enabled' : 'Disabled'}`);
|
||||
|
||||
// Show authoritative domains
|
||||
if (this.options.dnsScopes.length > 0) {
|
||||
console.log('\n Authoritative Domains:');
|
||||
this.options.dnsScopes.forEach((domain, index) => {
|
||||
const isLast = index === this.options.dnsScopes!.length - 1;
|
||||
console.log(` ${isLast ? '└─' : '├─'} ${domain}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Storage summary
|
||||
if (this.storageManager && this.options.storage) {
|
||||
console.log('\n💾 Storage:');
|
||||
console.log(` └─ Path: ${this.options.storage.fsPath || 'default'}`);
|
||||
}
|
||||
|
||||
console.log('\n✅ All services are running\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up SmartProxy with direct configuration and automatic email routes
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user