51 lines
937 B
Go
51 lines
937 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"runtime"
|
|
)
|
|
|
|
const (
|
|
appName = "rngpotd"
|
|
appVersion = "0.0.2"
|
|
userAgent = appName + "/" + appVersion
|
|
serverAgent = "nginx/1.27.1"
|
|
|
|
minimumGoMaxProcs = 4
|
|
maximumGoMaxProcs = 8
|
|
)
|
|
|
|
var (
|
|
listenEndpoint string
|
|
)
|
|
|
|
func init() {
|
|
flag.StringVar(&listenEndpoint, "listen", ":8888", "listen (\":port\", \"address:port\")")
|
|
}
|
|
|
|
func main() {
|
|
gmp := runtime.GOMAXPROCS(0)
|
|
if gmp < minimumGoMaxProcs {
|
|
runtime.GOMAXPROCS(minimumGoMaxProcs)
|
|
} else if gmp > maximumGoMaxProcs {
|
|
runtime.GOMAXPROCS(maximumGoMaxProcs)
|
|
}
|
|
|
|
log.SetFlags(log.Flags() | log.Lmicroseconds)
|
|
flag.Parse()
|
|
|
|
log.Printf("%s: starting\n", userAgent)
|
|
|
|
app := initFiberApp()
|
|
if app == nil {
|
|
log.Fatal("failed to initialize rngpotd")
|
|
}
|
|
|
|
log.Printf("%s: ready\n", userAgent)
|
|
log.Printf("%s: going to listen %q\n", userAgent, listenEndpoint)
|
|
if err := app.Listen(listenEndpoint); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|