|
@@ -2,10 +2,7 @@ package logic
|
|
|
|
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
- "errors"
|
|
|
|
"fmt"
|
|
"fmt"
|
|
- "golang.org/x/exp/slog"
|
|
|
|
- "os"
|
|
|
|
"sync"
|
|
"sync"
|
|
"time"
|
|
"time"
|
|
|
|
|
|
@@ -21,9 +18,6 @@ const timer_hours_between_runs = 24
|
|
// HookManagerCh - channel to add any new hooks
|
|
// HookManagerCh - channel to add any new hooks
|
|
var HookManagerCh = make(chan models.HookDetails, 2)
|
|
var HookManagerCh = make(chan models.HookDetails, 2)
|
|
|
|
|
|
-// HookManagerFatalError is an error to which is fatal to the hook manager (stops the program!)
|
|
|
|
-var HookManagerFatalError = errors.New("fatal periodic procedure")
|
|
|
|
-
|
|
|
|
// == Public ==
|
|
// == Public ==
|
|
|
|
|
|
// TimerCheckpoint - Checks if 24 hours has passed since telemetry was last sent. If so, sends telemetry data to posthog
|
|
// TimerCheckpoint - Checks if 24 hours has passed since telemetry was last sent. If so, sends telemetry data to posthog
|
|
@@ -76,13 +70,7 @@ func addHookWithInterval(ctx context.Context, wg *sync.WaitGroup, hook func() er
|
|
case <-ctx.Done():
|
|
case <-ctx.Done():
|
|
return
|
|
return
|
|
case <-ticker.C:
|
|
case <-ticker.C:
|
|
- if err := hook(); err != nil {
|
|
|
|
- // stop the server if there was a fatal error
|
|
|
|
- if errors.Is(err, HookManagerFatalError) {
|
|
|
|
- slog.Error(err.Error())
|
|
|
|
- os.Exit(0)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ hook()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|