Skip to content

Instantly share code, notes, and snippets.

@mhoran
Created March 23, 2018 16:19
Show Gist options
  • Save mhoran/4104409fb09585147472228de7295fc2 to your computer and use it in GitHub Desktop.
Save mhoran/4104409fb09585147472228de7295fc2 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"net/http"
"os"
"time"
)
func main() {
for i := 0; i < 15; i++ {
port := os.Getenv("PORT")
res, err := http.Get(fmt.Sprintf("http://localhost:%s", port))
if err == nil && res.StatusCode != 500 {
fmt.Println("app up")
os.Exit(0)
}
time.Sleep(1 * time.Second)
}
fmt.Println("app never came up")
os.Exit(1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment