storj/cmd/storagenode-updater/loop.go
Ethan Adams 27c6c6aeae
ci: Golangci lint v1.43.0 changes (#4307)
Co-authored-by: Stefan Benten <mail@stefan-benten.de>
2021-12-09 20:49:48 +01:00

39 lines
1.2 KiB
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
//go:build unittest || !windows
// +build unittest !windows
package main
import (
"context"
"go.uber.org/zap"
"storj.io/storj/private/version/checker"
)
// loopFunc is func that is run by the update cycle.
func loopFunc(ctx context.Context) error {
zap.L().Info("Downloading versions.", zap.String("Server Address", runCfg.Version.ServerAddress))
all, err := checker.New(runCfg.Version.ClientConfig).All(ctx)
if err != nil {
zap.L().Error("Error retrieving version info.", zap.Error(err))
return nil
}
if err := update(ctx, runCfg.ServiceName, runCfg.BinaryLocation, all.Processes.Storagenode); err != nil {
// don't finish loop in case of error just wait for another execution
zap.L().Error("Error updating service.", zap.String("Service", runCfg.ServiceName), zap.Error(err))
}
if err := update(ctx, updaterServiceName, updaterBinaryPath, all.Processes.StoragenodeUpdater); err != nil {
// don't finish loop in case of error just wait for another execution
zap.L().Error("Error updating service.", zap.String("Service", updaterServiceName), zap.Error(err))
}
return nil
}