Skip to content

Commit

Permalink
Small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Petri Autero committed Jan 11, 2019
1 parent 2286fe7 commit 02fe94c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ a single TCP port, or an HTTP(S) endpoint. As a result, our use case just isn't
We wrote health-checker so that we could run a daemon on the server that reports the true health of the server by
attempting to open a TCP connection to more than one port when it receives an inbound HTTP request on the given listener.

Using the `--script` -option, the `health-checker` can be extended to check many other targets. One concrete exeample is monitoring
Using the `--script` -option, the `health-checker` can be extended to check many other targets. One concrete example is monitoring
`ZooKeeper` node status during rolling deployment. Just polling the `ZooKeeper`'s TCP client port doesn't necessarily guarantee
that the node has (re-)joined the cluster. Using the `health-check` with a custom script target, we can
[monitor ZooKeeper](https://zookeeper.apache.org/doc/r3.4.8/zookeeperAdmin.html#sc_monitoring) using the
Expand Down
6 changes: 4 additions & 2 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ func runChecks(opts *options.Options) *httpResponse {
for _, script := range opts.Scripts {
waitGroup.Add(1)
go func(script options.Script) {

defer waitGroup.Done()

logger.Infof("Executing '%v' with a timeout of %v seconds...", script, opts.ScriptTimeout)

timeout := time.Second * time.Duration(opts.ScriptTimeout)

ctx, cancel := context.WithTimeout(context.Background(), timeout)

defer cancel()

cmd := exec.CommandContext(ctx, script.Name, script.Args...)
Expand All @@ -79,8 +83,6 @@ func runChecks(opts *options.Options) *httpResponse {
} else {
logger.Infof("Script %v successful", script)
}

waitGroup.Done()
}(script)
}

Expand Down

0 comments on commit 02fe94c

Please sign in to comment.