Init
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
milkwatch-pi
|
||||
2
build.sh
Executable file
2
build.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/zsh
|
||||
GOOS=linux GOARCH=arm GOARM=7 go build .
|
||||
3
go.mod
Normal file
3
go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module rodbiren.ddns.net/git/robviren/milkwatch-pi
|
||||
|
||||
go 1.17
|
||||
24
main.go
Normal file
24
main.go
Normal 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
13
milkwatch-pi.service
Normal 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
|
||||
Reference in New Issue
Block a user