예제 #1
0
		if len(args) != 1 {
			cmd.UsageFunc()(cmd)
			return
		}

		gtwID := args[0]
		if !api.ValidID(gtwID) {
			ctx.Fatal("Invalid Gateway ID")
		}

		conn, manager := util.GetRouterManager(ctx)
		defer conn.Close()

		ctx = ctx.WithField("GatewayID", gtwID)

		resp, err := manager.GatewayStatus(util.GetContext(ctx), &router.GatewayStatusRequest{
			GatewayId: gtwID,
		})
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatal("Could not get status of gateway.")
		}

		ctx.Infof("Received status")
		fmt.Println()
		printKV("Last seen", time.Unix(0, resp.LastSeen))
		printKV("Timestamp", resp.Status.Timestamp)
		if t := resp.Status.Time; t != 0 {
			printKV("Reported time", time.Unix(0, t))
		}
		printKV("Description", resp.Status.Description)
		printKV("Platform", resp.Status.Platform)
예제 #2
0
		serviceType := args[0]
		switch serviceType {
		case "router", "broker", "handler":
		default:
			ctx.Fatalf("Service type %s unknown", serviceType)
		}

		serviceID := args[1]
		if !api.ValidID(serviceID) {
			ctx.Fatalf("Service ID %s invalid", serviceID)
		}

		dscConn, client := util.GetDiscovery(ctx)
		defer dscConn.Close()

		res, err := client.Get(util.GetContext(ctx), &discovery.GetRequest{
			ServiceName: serviceType,
			Id:          serviceID,
		})
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatalf("Could not get %s %s", serviceType, serviceID)
		}

		conn, err := res.Dial()
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatalf("Could not dial %s %s", serviceType, serviceID)
		}
		defer conn.Close()

		start := time.Now()
		ok, err := health.Check(conn)
예제 #3
0
		switch serviceType {
		case "router":
			ctx.Info("Discovering routers...")
		case "broker":
			ctx.Info("Discovering brokers and their prefixes...")
		case "handler":
			ctx.Info("Discovering handlers and their apps...")
		default:
			ctx.Fatalf("Service type %s unknown", serviceType)
		}

		conn, client := util.GetDiscovery(ctx)
		defer conn.Close()

		res, err := client.GetAll(util.GetContext(ctx), &discovery.GetServiceRequest{
			ServiceName: serviceType,
		})
		if err != nil {
			ctx.WithError(errors.FromGRPCError(err)).Fatalf("Could not get %ss", serviceType)
		}

		ctx.Infof("Discovered %d %ss", len(res.Services), serviceType)

		fmt.Printf(serviceFmt, "ID", "ADDRESS", "VERSION", "PUBLIC")
		fmt.Printf(serviceFmt, "==", "=======", "=======", "======")
		fmt.Println()
		for _, service := range res.Services {
			fmt.Printf(serviceFmt, service.Id, crop(service.NetAddress, 36), crop(service.ServiceVersion, 20), fmt.Sprintf("%v", service.Public))
			if showMetadata, _ := cmd.Flags().GetBool("metadata"); showMetadata {
				switch serviceType {