logging url of service

This commit is contained in:
Stephen McQuay 2015-01-12 20:01:38 -08:00
parent d1f1cfcd67
commit 5c7addafb9

12
main.go
View File

@ -2,6 +2,7 @@ package main
import (
"flag"
"fmt"
"log"
"math/rand"
"net/http"
@ -13,7 +14,7 @@ import (
const MAX = 12
var addr = flag.String("addr", ":8000", "address I'll listen on.")
var port = flag.Int("port", 8000, "listen on this port")
var store = sessions.NewCookieStore([]byte(os.Getenv("MMG_SECRET_KEY")))
var statics map[string][]byte
@ -40,7 +41,14 @@ func main() {
"/reset/",
reset,
)
if err := http.ListenAndServe(*addr, nil); err != nil {
hostname, err := os.Hostname()
if err != nil {
log.Fatal("problem getting hostname:", err)
}
log.Printf("serving at: http://%s:%d/", hostname, *port)
if err := http.ListenAndServe(fmt.Sprintf(":%d", *port), nil); err != nil {
log.Fatal("ListenAndServe:", err)
}
}