2022-03-08 14:47:55 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-03-10 18:14:07 +01:00
|
|
|
"github.com/wiretrustee/wiretrustee/util"
|
2022-03-08 14:47:55 +01:00
|
|
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
|
|
|
|
"github.com/wiretrustee/wiretrustee/client/internal"
|
|
|
|
"github.com/wiretrustee/wiretrustee/client/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
var statusCmd = &cobra.Command{
|
|
|
|
Use: "status",
|
|
|
|
Short: "status of the Wiretrustee Service",
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
SetFlagsFromEnvVars()
|
2022-03-10 18:14:07 +01:00
|
|
|
|
2022-03-14 13:16:16 +01:00
|
|
|
err := util.InitLog(logLevel, "console")
|
2022-03-10 18:14:07 +01:00
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed initializing log %v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-03-08 14:47:55 +01:00
|
|
|
ctx := internal.CtxInitState(context.Background())
|
|
|
|
|
|
|
|
conn, err := DialClientGRPCServer(ctx, daemonAddr)
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("failed to connect to service CLI interface %v", err)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
resp, err := proto.NewDaemonServiceClient(conn).Status(cmd.Context(), &proto.StatusRequest{})
|
|
|
|
if err != nil {
|
|
|
|
log.Errorf("status failed: %v", status.Convert(err).Message())
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("status: %v", resp.Status)
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
}
|