mirror of
https://codeberg.org/cunicu/cunicu.git
synced 2025-10-06 17:27:07 +08:00
32 lines
637 B
Go
32 lines
637 B
Go
package main
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
|
||
"github.com/spf13/cobra"
|
||
"riasc.eu/wice/pkg/pb"
|
||
)
|
||
|
||
var stopCmd = &cobra.Command{
|
||
Use: "stop",
|
||
Short: "Shutdown the ɯice daemon",
|
||
RunE: stop,
|
||
Args: cobra.NoArgs,
|
||
}
|
||
|
||
func init() {
|
||
addClientCommand(RootCmd, stopCmd)
|
||
}
|
||
|
||
func stop(cmd *cobra.Command, args []string) error {
|
||
// TODO: Ignore errors caused by closed connection or gracefully shutdown the server
|
||
if rerr, err := client.Stop(context.Background(), &pb.StopParams{}); err != nil {
|
||
return fmt.Errorf("failed RPC request: %w", err)
|
||
} else if !rerr.Ok() {
|
||
return fmt.Errorf("received RPC error: %w", rerr)
|
||
}
|
||
|
||
return nil
|
||
}
|