mirror of
https://github.com/mainnika/nikita-tokarch-uk.git
synced 2026-05-25 01:03:35 +00:00
Listen http server in main thread
This commit is contained in:
@@ -2,9 +2,11 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
"github.com/valyala/fasthttp"
|
||||||
|
|
||||||
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/config"
|
"code.tokarch.uk/mainnika/nikita-tokarch-uk/frontend/config"
|
||||||
)
|
)
|
||||||
@@ -28,6 +30,33 @@ func main() {
|
|||||||
logrus.Warnf("Cannot unmarshal config, %v", err)
|
logrus.Warnf("Cannot unmarshal config, %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var netw, addr string
|
||||||
|
switch {
|
||||||
|
case config.Addr != "":
|
||||||
|
netw = "tcp"
|
||||||
|
addr = config.Addr
|
||||||
|
case config.Unix != "":
|
||||||
|
netw = "unix"
|
||||||
|
addr = config.Unix
|
||||||
|
default:
|
||||||
|
panic("no address given")
|
||||||
|
}
|
||||||
|
netListener, err := net.Listen(netw, addr)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
httpServer := fasthttp.Server{
|
||||||
|
Logger: logrus.StandardLogger(),
|
||||||
|
GetOnly: true,
|
||||||
|
}
|
||||||
|
|
||||||
logrus.Infof("Version: %s", Version)
|
logrus.Infof("Version: %s", Version)
|
||||||
|
logrus.Debugf("Addr: %s+%s", netw, addr)
|
||||||
logrus.Debugf("Conf: %#v", config)
|
logrus.Debugf("Conf: %#v", config)
|
||||||
|
|
||||||
|
err = httpServer.Serve(netListener)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user