Files
cunicu/cmd/stop.go
Steffen Vogel 410756f11c windows portability fixes
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
2022-08-04 00:20:43 +02:00

32 lines
637 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}