Skip to content

Commit

Permalink
Amp logs fix (#340)
Browse files Browse the repository at this point in the history
* Fixing log command

* Fixing log command
  • Loading branch information
qube authored and freignat91 committed Oct 18, 2016
1 parent bb1a915 commit 426291d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
22 changes: 5 additions & 17 deletions api/server/server_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"os"
"strings"

"context"
"github.com/appcelerator/amp/api/rpc/logs"
"google.golang.org/grpc"
"log"
"time"
Expand Down Expand Up @@ -88,24 +86,14 @@ func StartTestServer() (Config, *grpc.ClientConn) {

// Connect to amplifier
log.Println("Connecting to amplifier")
conn, err := grpc.Dial(serverAddress, grpc.WithInsecure(), grpc.WithTimeout(60*time.Second))
conn, err := grpc.Dial(serverAddress,
grpc.WithInsecure(),
grpc.WithBlock(),
grpc.WithTimeout(60*time.Second))
if err != nil {
log.Panicln("Amplifier is not ready", err)
log.Panicln("Cannot connect to amplifier", err)
}
log.Println("Connected to amplifier")

// Use the connection to amplifier
logsClient := logs.NewLogsClient(conn)
for i := 0; i < 60; i++ {
_, err := logsClient.Get(context.Background(), &logs.GetRequest{})
if err != nil {
log.Println("Connection to amplifier not ready yet: ", err)
time.Sleep(100 * time.Millisecond)
continue
}
break
}
log.Println("Ready")

return config, conn
}
6 changes: 5 additions & 1 deletion cmd/amp/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ var logsCmd = &cobra.Command{
Use: "logs [OPTIONS] [SERVICE]",
Short: "Fetch log entries matching provided criteria. If provided, SERVICE can be a partial or full service id or service name.",
Run: func(cmd *cobra.Command, args []string) {
AMP.Connect()
err := Logs(AMP, cmd, args)
if err != nil {
fmt.Println(err)
if AMP.Verbose() {
log.Println(err)
}
log.Fatal("Failed to get logs")
}
},
}
Expand Down

0 comments on commit 426291d

Please sign in to comment.