2020-04-01 12:59:34 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
// +build unittest !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"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 {
|
2020-06-08 22:25:30 +01:00
|
|
|
zap.L().Info("Downloading versions.", zap.String("Server Address", runCfg.Version.ServerAddress))
|
2020-04-01 12:59:34 +01:00
|
|
|
|
2020-06-08 22:25:30 +01:00
|
|
|
all, err := checker.New(runCfg.Version.ClientConfig).All(ctx)
|
2020-04-01 12:59:34 +01:00
|
|
|
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))
|
|
|
|
}
|
|
|
|
|
|
|
|
updaterBinName := os.Args[0]
|
|
|
|
if err := update(ctx, updaterServiceName, updaterBinName, 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
|
|
|
|
}
|