2018-01-16 20:57:04 -08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"net/http"
|
2018-01-20 09:07:57 -08:00
|
|
|
"os"
|
2018-01-16 20:57:04 -08:00
|
|
|
|
2018-01-21 13:57:31 -08:00
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
2018-01-16 20:57:04 -08:00
|
|
|
"mcquay.me/hwt"
|
2018-01-20 08:38:58 -08:00
|
|
|
pb "mcquay.me/hwt/rpc/hwt"
|
2018-01-16 20:57:04 -08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2018-01-20 09:07:57 -08:00
|
|
|
hn, err := os.Hostname()
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalf("cannot get hostname: %v", err)
|
|
|
|
}
|
|
|
|
s := &hwt.Server{hn}
|
2018-01-20 08:38:58 -08:00
|
|
|
th := pb.NewHelloWorldServer(s, nil)
|
2018-01-21 13:57:31 -08:00
|
|
|
sm := http.NewServeMux()
|
|
|
|
sm.Handle("/", th)
|
|
|
|
sm.Handle("/metrics", promhttp.Handler())
|
|
|
|
if err := http.ListenAndServe(":8080", sm); err != nil {
|
2018-01-16 20:57:04 -08:00
|
|
|
log.Fatalf("listen and serve: %v", err)
|
|
|
|
}
|
|
|
|
}
|