Skip to content

Commit 9d03e61

Browse files
author
Francesc Campoy
committed
ping early to check whether the program works
Change-Id: I098939d608701862dcce23b785e04b561ecb68da
1 parent db219be commit 9d03e61

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

logpipe.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323
"os"
2424
"os/signal"
25+
"time"
2526

2627
flags "github.com/jessevdk/go-flags"
2728

@@ -54,6 +55,13 @@ func main() {
5455
if err != nil {
5556
errorf("Failed to create client: %v", err)
5657
}
58+
59+
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
60+
defer cancel()
61+
if err := client.Ping(ctx); err != nil {
62+
errorf("Failed to ping logging service: %v", err)
63+
}
64+
5765
// Selects the log to write to.
5866
logger := client.Logger(opts.LogName)
5967

0 commit comments

Comments
 (0)