From 6d248b5cf083200929c7cf602d15473449aea2fd Mon Sep 17 00:00:00 2001 From: George Shammas Date: Fri, 15 May 2015 20:33:27 -0400 Subject: [PATCH] Listen on both the FCGI port and the webport! --- Dockerfile | 2 ++ main.go | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 427a754..da67e2a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,3 @@ FROM golang:1.4-onbuild + +EXPOSE 8080 diff --git a/main.go b/main.go index ef7cc73..7c0f952 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "net" "net/http" "net/http/fcgi" + "os" "path" "strings" "time" @@ -143,15 +144,21 @@ func main() { if err != nil { panic(err) } - err = fcgi.Serve(fcgi_listen, r) - if err != nil { - panic(err) - } + errc := make(chan error) + go func(errc chan error) { + for err := range errc { + panic(err) + } + }(errc) - //port := os.Getenv("PORT") - //host := os.Getenv("HOST") - //if port == "" { - // port = "8080" - //} - //r.Run(host + ":" + port) + go func(errc chan error) { + errc <- fcgi.Serve(fcgi_listen, r) + }(errc) + + port := os.Getenv("PORT") + host := os.Getenv("HOST") + if port == "" { + port = "8080" + } + errc <- r.Run(host + ":" + port) }