Add systemd socket support
This commit is contained in:
parent
0a392f3e90
commit
c8cd9ee648
13
main.go
13
main.go
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/brandfolder/gin-gorelic"
|
"github.com/brandfolder/gin-gorelic"
|
||||||
|
"github.com/coreos/go-systemd/activation"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Logger is a simple log handler, out puts in the standard of apache access log common.
|
// Logger is a simple log handler, out puts in the standard of apache access log common.
|
||||||
|
@ -189,6 +190,18 @@ func main() {
|
||||||
errc <- fcgi.Serve(fcgi_listen, r)
|
errc <- fcgi.Serve(fcgi_listen, r)
|
||||||
}(errc)
|
}(errc)
|
||||||
|
|
||||||
|
|
||||||
|
// Listen on whatever systemd tells us to.
|
||||||
|
listeners, err := activation.Listeners(true)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("Could not get systemd listerns with err %q", err)
|
||||||
|
}
|
||||||
|
for _, listener := range listeners {
|
||||||
|
go func(errc chan error) {
|
||||||
|
errc <- http.Serve(listener, r)
|
||||||
|
}(errc)
|
||||||
|
}
|
||||||
|
|
||||||
port := os.Getenv("PORT")
|
port := os.Getenv("PORT")
|
||||||
host := os.Getenv("HOST")
|
host := os.Getenv("HOST")
|
||||||
if port == "" {
|
if port == "" {
|
||||||
|
|
Loading…
Reference in New Issue