Browse Source

support running on $PORT

Lucas Stadler 11 years ago
parent
commit
b02660f20c
1 changed files with 7 additions and 1 deletions
  1. 7 1
      go/favicon.go

+ 7 - 1
go/favicon.go

13
	"github.com/golang/groupcache/lru"
13
	"github.com/golang/groupcache/lru"
14
)
14
)
15
15
16
var port = "8080"
17
16
var faviconCache = lru.New(10000)
18
var faviconCache = lru.New(10000)
17
var lock sync.RWMutex
19
var lock sync.RWMutex
18
20
19
func main() {
21
func main() {
20
	http.HandleFunc("/favicon", HandleGetFavicon)
22
	http.HandleFunc("/favicon", HandleGetFavicon)
21
	err := http.ListenAndServe(":8080", nil)
23
	if p := os.Getenv("PORT"); p != "" {
24
		port = p
25
	}
26
	fmt.Printf("listening on :%s\n", port)
27
	err := http.ListenAndServe(fmt.Sprintf(":%s", port), nil)
22
28
23
	if err != nil {
29
	if err != nil {
24
		fmt.Println("error: ", err)
30
		fmt.Println("error: ", err)