From ee2ecc09ce8311d123e86d0640dfd53c4823eb1c Mon Sep 17 00:00:00 2001 From: mbana Date: Wed, 21 Mar 2018 16:25:04 +0000 Subject: [PATCH 1/5] restructure cmd packages. --- cmd/{ => blondie}/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename cmd/{ => blondie}/main.go (99%) diff --git a/cmd/main.go b/cmd/blondie/main.go similarity index 99% rename from cmd/main.go rename to cmd/blondie/main.go index eb030c5..d953e79 100644 --- a/cmd/main.go +++ b/cmd/blondie/main.go @@ -1,4 +1,4 @@ -package main +package blondie import ( "flag" From 628ec7df5b7ca5261974ddb6929e36118c76f91e Mon Sep 17 00:00:00 2001 From: mbana Date: Wed, 21 Mar 2018 16:30:06 +0000 Subject: [PATCH 2/5] another attempt. --- cmd/blondie/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/blondie/main.go b/cmd/blondie/main.go index d953e79..eb030c5 100644 --- a/cmd/blondie/main.go +++ b/cmd/blondie/main.go @@ -1,4 +1,4 @@ -package blondie +package main import ( "flag" From 0e3420fb0494a4f9e512cd5506826753da404551 Mon Sep 17 00:00:00 2001 From: mbana Date: Wed, 21 Mar 2018 16:37:44 +0000 Subject: [PATCH 3/5] update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 6a52ac9..dbfaae5 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,23 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/myles-mcdonnell/blondie)](https://goreportcard.com/report/github.com/myles-mcdonnell/blondie) +## install +```sh +go get -u github.com/banaio/blondie/... +blondie -help +Usage of blondie: + -exit-code-on-connect int + Exit code when connection is made + -exit-code-on-fail int + Exit code when connection is not made (default 1) + -poll-interval int + poll interval in milliseconds (default 250) + -quiet-mode + suppress all output + -targets string + comma separated protocol:address:port:timeoutSeconds:[path]:[successcode], e.g. [tcp|http|https]:localhost:8080:60:[path]:[success_error_code] timeout is optional in which case the global timeout is used, final two arguments for htyp only +``` + A command that polls one or more TCP sockets/HTTP endpoints until a connection is made or the timeout is hit. Useful if you need to wait for a server or group of servers to start before doing something else. Why call it Blondie? This is the best I could come up with in the 5 seconds I allowed for naming it [https://www.youtube.com/watch?v=uWhkbDMISl8](https://www.youtube.com/watch?v=uWhkbDMISl8) From 7d54550edc12324754efbebece2ba1f8cc77b7db Mon Sep 17 00:00:00 2001 From: mbana Date: Wed, 21 Mar 2018 20:12:16 +0000 Subject: [PATCH 4/5] use `Printf` instead of `Println` as %s is being used. --- cmd/blondie/main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmd/blondie/main.go b/cmd/blondie/main.go index eb030c5..06f19ce 100644 --- a/cmd/blondie/main.go +++ b/cmd/blondie/main.go @@ -11,7 +11,6 @@ import ( ) func main() { - targets := flag.String("targets", "", "comma separated protocol:address:port:timeoutSeconds:[path]:[successcode], e.g. [tcp|http|https]:localhost:8080:60:[path]:[success_error_code] timeout is optional in which case the global timeout is used, final two arguments for htyp only") pollinterval := flag.Int("poll-interval", 250, "poll interval in milliseconds") exitCodeOnConnectOk := flag.Int("exit-code-on-connect", 0, "Exit code when connection is made") @@ -49,7 +48,7 @@ func main() { var err error var port int if port, err = strconv.Atoi(protoAddrPortAndTimeout[2]); err != nil { - fmt.Println("Unable to parse port %s", protoAddrPortAndTimeout[2]) + fmt.Printf("Unable to parse port %s", protoAddrPortAndTimeout[2]) os.Exit(*exitCodeOnConnectFail) } @@ -74,7 +73,7 @@ func main() { if len(protoAddrPortAndTimeout) > 5 { successcode, err := strconv.Atoi(protoAddrPortAndTimeout[5]) if err != nil { - fmt.Println("Can not parse success code to int %s", protoAddrPortAndTimeout[5]) + fmt.Printf("Can not parse success code to int %s", protoAddrPortAndTimeout[5]) os.Exit(*exitCodeOnConnectFail) } else { successcodes = []int{successcode} @@ -85,7 +84,7 @@ func main() { depChecks[index] = blondie.NewHttpCheck(host, port, timeout, path, successcodes) break default: - fmt.Println("Unsupported protocol %s", protocol) + fmt.Printf("Unsupported protocol %s", protocol) os.Exit(*exitCodeOnConnectFail) } From cf5f9c5d5567b68142f3d575fddd42f3631347e7 Mon Sep 17 00:00:00 2001 From: mbana Date: Thu, 22 Mar 2018 09:19:28 +0000 Subject: [PATCH 5/5] fix README instructions to use original repo url. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dbfaae5..f63b1b6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ## install ```sh -go get -u github.com/banaio/blondie/... +go get -u github.com/myles-mcdonnell/blondie/... blondie -help Usage of blondie: -exit-code-on-connect int