2020-04-01 12:59:34 +01:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
2019-11-14 14:03:49 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2022-12-13 10:12:24 +00:00
|
|
|
//go:build !service || (!windows && !linux && !freebsd && !dragonfly && !netbsd && !openbsd && !solaris && !darwin && service)
|
|
|
|
// +build !service !windows,!linux,!freebsd,!dragonfly,!netbsd,!openbsd,!solaris,!darwin,service
|
2019-11-14 14:03:49 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-04-01 12:59:34 +01:00
|
|
|
"context"
|
2019-11-14 14:03:49 +00:00
|
|
|
"os"
|
|
|
|
|
2020-04-01 12:59:34 +01:00
|
|
|
"github.com/spf13/cobra"
|
2019-11-14 14:03:49 +00:00
|
|
|
"github.com/zeebo/errs"
|
|
|
|
)
|
|
|
|
|
2020-04-01 12:59:34 +01:00
|
|
|
func cmdRestart(cmd *cobra.Command, args []string) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func restartService(ctx context.Context, service, binaryLocation, newVersionPath, backupPath string) error {
|
|
|
|
if err := os.Rename(binaryLocation, backupPath); err != nil {
|
|
|
|
return errs.Wrap(err)
|
2019-11-14 14:03:49 +00:00
|
|
|
}
|
2020-04-01 12:59:34 +01:00
|
|
|
|
|
|
|
if err := os.Rename(newVersionPath, binaryLocation); err != nil {
|
|
|
|
return errs.Combine(err, os.Rename(backupPath, binaryLocation), os.Remove(newVersionPath))
|
|
|
|
}
|
|
|
|
|
2019-11-14 14:03:49 +00:00
|
|
|
return nil
|
|
|
|
}
|