Skip to content

Instantly share code, notes, and snippets.

@simonjefford
Last active June 13, 2016 09:57
Show Gist options
  • Save simonjefford/782a43199d33c16627a02b6b50d2510a to your computer and use it in GitHub Desktop.
Save simonjefford/782a43199d33c16627a02b6b50d2510a to your computer and use it in GitHub Desktop.
package main
import (
"io/ioutil"
"log"
"net/http"
"os/exec"
"time"
)
func main() {
err := exec.Command("growlnotify", "-m", "starting").Run()
if err != nil {
log.Fatal(err)
}
c := &http.Client{}
for {
log.Println("checking")
res, err := c.Get("http://www.hamiltonthemusical.co.uk")
if err != nil {
log.Println(err)
}
body, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
log.Println(err)
continue
}
if string(body) != "site" {
log.Println("huzzah")
err := exec.Command("growlnotify", "-m", "site is live - probably")
if err != nil {
log.Println(err)
}
}
time.Sleep(15 * time.Minute)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment