feat(02-02): wire BackupScheduler into main.go lifecycle
- Create BackupScheduler with all dependencies injected - Run as goroutine parallel to status poll scheduler - Shares same context for graceful shutdown via SIGINT/SIGTERM - Startup logged with interval, max_concurrent, command_timeout Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -275,6 +275,36 @@ func main() {
|
|||||||
"conn_timeout", connTimeout,
|
"conn_timeout", connTimeout,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
// Start the config backup scheduler
|
||||||
|
// -----------------------------------------------------------------------
|
||||||
|
backupInterval := time.Duration(cfg.ConfigBackupIntervalSeconds) * time.Second
|
||||||
|
backupCmdTimeout := time.Duration(cfg.ConfigBackupCommandTimeoutSeconds) * time.Second
|
||||||
|
|
||||||
|
backupScheduler := poller.NewBackupScheduler(
|
||||||
|
deviceStore,
|
||||||
|
deviceStore, // SSHHostKeyUpdater (DeviceStore satisfies this interface)
|
||||||
|
locker,
|
||||||
|
publisher,
|
||||||
|
credentialCache,
|
||||||
|
redisClient,
|
||||||
|
backupInterval,
|
||||||
|
backupCmdTimeout,
|
||||||
|
refreshPeriod, // reuse existing device refresh period
|
||||||
|
cfg.ConfigBackupMaxConcurrent,
|
||||||
|
)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
slog.Info("starting config backup scheduler",
|
||||||
|
"interval", backupInterval,
|
||||||
|
"max_concurrent", cfg.ConfigBackupMaxConcurrent,
|
||||||
|
"command_timeout", backupCmdTimeout,
|
||||||
|
)
|
||||||
|
if err := backupScheduler.Run(ctx); err != nil {
|
||||||
|
slog.Error("backup scheduler exited with error", "error", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
if err := scheduler.Run(ctx); err != nil {
|
if err := scheduler.Run(ctx); err != nil {
|
||||||
slog.Error("scheduler exited with error", "error", err)
|
slog.Error("scheduler exited with error", "error", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user