Skip to content
This repository has been archived by the owner on May 6, 2021. It is now read-only.

Commit

Permalink
refactored code and added more logging for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
sathishvj committed Aug 22, 2017
1 parent 3496ac2 commit c0ee862
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
.glide/

# build outputs
fabric8-dependency-wait-service
fabric8-dependency-wait-service*
out/*
release/*
release/*
28 changes: 24 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ var PollIntervals = []int{

}

var gVerbose bool

func main() {

gVerbose = true

if len(os.Args) == 1 {
return
}
Expand Down Expand Up @@ -83,6 +87,10 @@ func pollHTTP200(url string, pollIntervals []int) (bool, int) {
log.Printf("\tNext poll after %d seconds.\n", pollInt)
totSecs += pollInt
time.Sleep(time.Second * time.Duration(pollInt))

if gVerbose {
log.Printf("\tGoing to checck %s\n", url)
}
ok := httpPoll(url)
if ok {
isUp = true
Expand Down Expand Up @@ -144,11 +152,23 @@ func pollPostgres(url string, pollIntervals []int, useDbPing bool) (bool, int) {
if !useDbPing {
var out []byte
username = strings.TrimSpace(username)
if len(username) == 0 {
out, _ = captureOutput(exec.Command(pg_isready, "-h", host, "-p", port))
} else {
out, _ = captureOutput(exec.Command(pg_isready, "-h", host, "-p", port, "-U", username))

exe := pg_isready
args := []string{
"-h", host,
"-p", port,
}

if len(username) > 0 {
args = append(args, []string{"-U", username}...)
}

if gVerbose {
log.Printf("\tGoing to execute: %s, %v\n", exe, args)
}

out, _ = captureOutput(exec.Command(exe, args...))

log.Print("\tpg_isready response: " + string(out))
if bytes.Index(out, []byte("accepting connections")) >= 0 {
isUp = true
Expand Down

0 comments on commit c0ee862

Please sign in to comment.