Listen on both the FCGI port and the webport!

This commit is contained in:
George Shammas 2015-05-15 20:33:27 -04:00
parent ba2b86deb9
commit 6d248b5cf0
2 changed files with 19 additions and 10 deletions

View File

@ -1 +1,3 @@
FROM golang:1.4-onbuild
EXPOSE 8080

27
main.go
View File

@ -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)
}