Feature: Unix domain socket support (#492)
Co-authored-by: Khanh Ngo <k@ndk.name>
This commit is contained in:
18
main.go
18
main.go
@@ -8,6 +8,9 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
"strings"
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/gommon/log"
|
||||
@@ -229,7 +232,20 @@ func main() {
|
||||
// serves other static files
|
||||
app.GET(util.BasePath+"/static/*", echo.WrapHandler(http.StripPrefix(util.BasePath+"/static/", assetHandler)))
|
||||
|
||||
app.Logger.Fatal(app.Start(util.BindAddress))
|
||||
if strings.HasPrefix(util.BindAddress, "unix://") {
|
||||
// Listen on unix domain socket.
|
||||
// https://github.com/labstack/echo/issues/830
|
||||
syscall.Unlink(util.BindAddress[6:])
|
||||
l, err := net.Listen("unix", util.BindAddress[6:])
|
||||
if err != nil {
|
||||
app.Logger.Fatal(err)
|
||||
}
|
||||
app.Listener = l
|
||||
app.Logger.Fatal(app.Start(""))
|
||||
} else {
|
||||
// Listen on TCP socket
|
||||
app.Logger.Fatal(app.Start(util.BindAddress))
|
||||
}
|
||||
}
|
||||
|
||||
func initServerConfig(db store.IStore, tmplDir fs.FS) {
|
||||
|
||||
Reference in New Issue
Block a user