Changelog v0.4.0

This commit is contained in:
Mukhtar Akere
2025-01-18 03:49:05 +01:00
parent ea73572557
commit 3841b7751e
30 changed files with 298 additions and 195 deletions

View File

@@ -14,7 +14,7 @@ import (
func Start(ctx context.Context, config *common.Config, arrs *arr.Storage) error {
ctx, stop := signal.NotifyContext(ctx, os.Interrupt, syscall.SIGTERM)
logger := common.NewLogger("Repair", os.Stdout)
logger := common.NewLogger("Repair", config.LogLevel, os.Stdout)
defer stop()
duration, err := parseSchedule(config.Repair.Interval)
@@ -23,7 +23,7 @@ func Start(ctx context.Context, config *common.Config, arrs *arr.Storage) error
}
if config.Repair.RunOnStart {
logger.Printf("Running initial repair")
logger.Info().Msgf("Running initial repair")
if err := repair(arrs); err != nil {
log.Printf("Error during initial repair: %v", err)
return err
@@ -34,20 +34,20 @@ func Start(ctx context.Context, config *common.Config, arrs *arr.Storage) error
defer ticker.Stop()
if strings.Contains(config.Repair.Interval, ":") {
logger.Printf("Starting repair worker, scheduled daily at %s", config.Repair.Interval)
logger.Info().Msgf("Starting repair worker, scheduled daily at %s", config.Repair.Interval)
} else {
logger.Printf("Starting repair worker with %v interval", duration)
logger.Info().Msgf("Starting repair worker with %v interval", duration)
}
for {
select {
case <-ctx.Done():
logger.Println("Repair worker stopped")
logger.Info().Msg("Repair worker stopped")
return nil
case t := <-ticker.C:
logger.Printf("Running repair at %v", t.Format("15:04:05"))
logger.Info().Msgf("Running repair at %v", t.Format("15:04:05"))
if err := repair(arrs); err != nil {
logger.Printf("Error during repair: %v", err)
logger.Info().Msgf("Error during repair: %v", err)
return err
}
@@ -55,7 +55,7 @@ func Start(ctx context.Context, config *common.Config, arrs *arr.Storage) error
if strings.Contains(config.Repair.Interval, ":") {
nextDuration, err := parseSchedule(config.Repair.Interval)
if err != nil {
logger.Printf("Error calculating next schedule: %v", err)
logger.Info().Msgf("Error calculating next schedule: %v", err)
return err
}
ticker.Reset(nextDuration)