This commit is contained in:
2021-11-07 20:38:39 -06:00
commit 2143481a89
5 changed files with 43 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
milkwatch-pi

2
build.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/zsh
GOOS=linux GOARCH=arm GOARM=7 go build .

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module rodbiren.ddns.net/git/robviren/milkwatch-pi
go 1.17

24
main.go Normal file
View File

@@ -0,0 +1,24 @@
package main
import (
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/heartbeat", func(res http.ResponseWriter, req *http.Request) {
log.Println("Working as expected")
data := []byte("Totally Alive")
res.WriteHeader(200)
res.Write(data)
})
//Create the server.
s := &http.Server{
Addr: ":2122",
Handler: mux,
}
s.ListenAndServe()
}

13
milkwatch-pi.service Normal file
View File

@@ -0,0 +1,13 @@
[Unit]
Description=Milkwatch on pi
After=network.target
[Service]
Type=simple
User=robviren
Group=robviren
ExecStart=milkwatch-pi
Restart=on-failure
[Install]
WantedBy=multi-user.target