parent
cc534d83da
commit
0e3fc9cb80
7
Makefile
7
Makefile
|
@ -2,9 +2,14 @@ all:
|
|||
-git pull
|
||||
echo "build it!"
|
||||
GO111MODULE=off go build -v -x
|
||||
./powerpaneld
|
||||
./powerpaneld --hostname=breen
|
||||
# su -c "setcap 'cap_net_bind_service=+ep' go.wit.com"
|
||||
|
||||
run:
|
||||
GO111MODULE=off go build -v -x
|
||||
-systemctl stop powerpaneld.service
|
||||
./powerpaneld
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
/*
|
||||
this parses the command line arguements
|
||||
|
||||
this enables command line options from other packages like 'gui' and 'log'
|
||||
*/
|
||||
|
||||
import (
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
)
|
||||
|
||||
var args struct {
|
||||
ListRepos bool `arg:"--list-repos" help:"list all repositories"`
|
||||
Port int `arg:"--port" help:"port to run on (default is 2520)"`
|
||||
Hostname string `arg:"--hostname" help:"hostname to use"`
|
||||
}
|
||||
|
||||
func init() {
|
||||
arg.MustParse(&args)
|
||||
}
|
10
main.go
10
main.go
|
@ -45,6 +45,16 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func main() {
|
||||
var hostname string = args.Hostname
|
||||
|
||||
if hostname == "" {
|
||||
hostname = "localhost"
|
||||
}
|
||||
|
||||
log.Info("curl http://" + hostname + ":3000/powersource # shows if your power grid is up")
|
||||
log.Info("curl http://" + hostname + ":3000/lastoutage # shows the last time your power grid went down")
|
||||
log.Info("hostname =", hostname)
|
||||
|
||||
http.HandleFunc("/", okHandler)
|
||||
err := http.ListenAndServe(":3000", nil)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue