Add reliability improvements and config persistence feature
- Implement context cleanup with sync.Once and io.Closer interface - Add regex-based error classification for robust error handling - Create ProcessManager with thread-safe process tracking - Add disk space caching with 30s TTL for performance - Implement metrics collection with structured logging - Add config persistence (.dbbackup.conf) for directory-local settings - Auto-save/auto-load configuration with --no-config and --no-save-config flags - Successfully tested with 42GB d7030 database (35K large objects, 36min backup) - All cross-platform builds working (9/10 platforms)
This commit is contained in:
16
main.go
16
main.go
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -10,6 +11,7 @@ import (
|
||||
"dbbackup/cmd"
|
||||
"dbbackup/internal/config"
|
||||
"dbbackup/internal/logger"
|
||||
"dbbackup/internal/metrics"
|
||||
)
|
||||
|
||||
// Build information (set by ldflags)
|
||||
@@ -42,6 +44,20 @@ func main() {
|
||||
// Initialize logger
|
||||
log := logger.New(cfg.LogLevel, cfg.LogFormat)
|
||||
|
||||
// Initialize global metrics
|
||||
metrics.InitGlobalMetrics(log)
|
||||
|
||||
// Show session summary on exit
|
||||
defer func() {
|
||||
if metrics.GlobalMetrics != nil {
|
||||
avgs := metrics.GlobalMetrics.GetAverages()
|
||||
if ops, ok := avgs["total_operations"].(int); ok && ops > 0 {
|
||||
fmt.Printf("\n📊 Session Summary: %d operations, %.1f%% success rate\n",
|
||||
ops, avgs["success_rate"])
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Execute command
|
||||
if err := cmd.Execute(ctx, cfg, log); err != nil {
|
||||
log.Error("Application failed", "error", err)
|
||||
|
||||
Reference in New Issue
Block a user