Last active
June 13, 2016 09:57
-
-
Save simonjefford/782a43199d33c16627a02b6b50d2510a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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