mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-07 07:07:10 +02:00
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
// nolint: dupl,golint
|
|
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/autonomy/talos/internal/app/osctl/internal/client"
|
|
"github.com/autonomy/talos/internal/app/osd/proto"
|
|
"github.com/autonomy/talos/internal/pkg/constants"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
timeout int32
|
|
)
|
|
|
|
// restartCmd represents the restart command
|
|
var restartCmd = &cobra.Command{
|
|
Use: "restart",
|
|
Short: "Restart a process",
|
|
Long: ``,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 1 {
|
|
if err := cmd.Usage(); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
os.Exit(1)
|
|
}
|
|
creds, err := client.NewDefaultClientCredentials()
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
c, err := client.NewClient(constants.OsdPort, creds)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
r := &proto.RestartRequest{
|
|
Id: args[0],
|
|
Timeout: timeout,
|
|
}
|
|
if err := c.Restart(r); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
restartCmd.Flags().Int32VarP(&timeout, "timeout", "t", 60, "the timeout duration in seconds")
|
|
rootCmd.AddCommand(restartCmd)
|
|
}
|